Mercurial > emacs
annotate lisp/textmodes/sgml-mode.el @ 110024:5428546bbb98
Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
* gnus-html.el: Start a new super-simple HTML renderer based on w3m.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Mon, 30 Aug 2010 06:13:50 +0000 |
parents | d835100c3e8b |
children | b10051866f51 |
rev | line source |
---|---|
104325
c730723a8c88
Change to utf-8. Adjust coding cookie.
Kenichi Handa <handa@m17n.org>
parents:
101003
diff
changeset
|
1 ;;; sgml-mode.el --- SGML- and HTML-editing modes -*- coding: utf-8 -*- |
809 | 2 |
64751
5b1a238fcbb4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 ;; Copyright (C) 1992, 1995, 1996, 1998, 2001, 2002, 2003, 2004, |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
844
bf829a2d63b4
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
828
diff
changeset
|
5 |
17432
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
6 ;; Author: James Clark <jjc@jclark.com> |
43692
568974ab1796
Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43589
diff
changeset
|
7 ;; Maintainer: FSF |
23869 | 8 ;; 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
|
9 ;; F.Potorti@cnuce.cnr.it |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
10 ;; Keywords: wp, hypermedia, comm, languages |
809 | 11 |
12 ;; This file is part of GNU Emacs. | |
13 | |
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92748
diff
changeset
|
14 ;; GNU Emacs is free software: you can redistribute it and/or modify |
809 | 15 ;; it under the terms of the GNU General Public License as published by |
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92748
diff
changeset
|
16 ;; the Free Software Foundation, either version 3 of the License, or |
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92748
diff
changeset
|
17 ;; (at your option) any later version. |
809 | 18 |
19 ;; GNU Emacs is distributed in the hope that it will be useful, | |
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 ;; GNU General Public License for more details. | |
23 | |
24 ;; You should have received a copy of the GNU General Public License | |
94670
f4a69fedbd46
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
92748
diff
changeset
|
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
809 | 26 |
27 ;;; Commentary: | |
28 | |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
29 ;; 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
|
30 ;; 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
|
31 ;; HTML hypertext markup language. |
809 | 32 |
33 ;;; Code: | |
34 | |
25175 | 35 (eval-when-compile |
36 (require 'skeleton) | |
44388
01d388c4b0a3
Remember to (require 'cl).
Mike Williams <mdub@bigfoot.com>
parents:
44387
diff
changeset
|
37 (require 'outline) |
01d388c4b0a3
Remember to (require 'cl).
Mike Williams <mdub@bigfoot.com>
parents:
44387
diff
changeset
|
38 (require 'cl)) |
23726 | 39 |
17432
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
40 (defgroup sgml nil |
64058
7e00d33823d3
(sgml): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63521
diff
changeset
|
41 "SGML editing mode." |
66963
a11fdee52c05
Add :link (custom-group-link font-lock-faces) to defgroup.
Juri Linkov <juri@jurta.org>
parents:
65175
diff
changeset
|
42 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces) |
17432
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
43 :group 'languages) |
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
44 |
44241
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
45 (defcustom sgml-basic-offset 2 |
80889
8938fa90afdb
(sgml-value): Fix handling of attributes which can take any number of values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80876
diff
changeset
|
46 "Specifies the basic indentation level for `sgml-indent-line'." |
44241
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
47 :type 'integer |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
48 :group 'sgml) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
49 |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
50 (defcustom sgml-transformation-function 'identity |
80889
8938fa90afdb
(sgml-value): Fix handling of attributes which can take any number of values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80876
diff
changeset
|
51 "Default value for `skeleton-transformation-function' in SGML mode." |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
52 :type 'function |
17530
9fb83ef40566
(sgml-transformation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
17500
diff
changeset
|
53 :group 'sgml) |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
54 |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
55 (put 'sgml-transformation-function 'variable-interactive |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
56 "aTransformation function: ") |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
57 (defvaralias 'sgml-transformation 'sgml-transformation-function) |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
58 |
25175 | 59 (defcustom sgml-mode-hook nil |
60 "Hook run by command `sgml-mode'. | |
61 `text-mode-hook' is run first." | |
62 :group 'sgml | |
63 :type 'hook) | |
64 | |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
65 ;; 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
|
66 ;; 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
|
67 ;; kludgy kind of tradeoff. |
16404
0cdf66e69ad8
(sgml-specials): Delete `-' from the list.
Richard M. Stallman <rms@gnu.org>
parents:
15867
diff
changeset
|
68 (defvar sgml-specials '(?\") |
17551 | 69 "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
|
70 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
|
71 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
|
72 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
73 ?\\\" Makes \" in text start a string. |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
74 ?' Makes ' in text start a string. |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
75 ?- Makes -- in text start a comment. |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
76 |
22319
18b5b2445726
(sgml-font-lock-keywords-1): Add -. as
Dave Love <fx@gnu.org>
parents:
22222
diff
changeset
|
77 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
|
78 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
|
79 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
|
80 |
0cdf66e69ad8
(sgml-specials): Delete `-' from the list.
Richard M. Stallman <rms@gnu.org>
parents:
15867
diff
changeset
|
81 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
|
82 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
|
83 |
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
84 (defvar sgml-quick-keys nil |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
85 "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
|
86 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
|
87 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
88 (defvar sgml-mode-map |
38068
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
89 (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
|
90 (menu-map (make-sparse-keymap "SGML"))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
91 (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
|
92 (define-key map "/" 'sgml-slash) |
14270
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
93 (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
|
94 (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
|
95 (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
|
96 (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
|
97 (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
|
98 (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
|
99 (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
|
100 (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
|
101 (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
|
102 (define-key map "\C-c?" 'sgml-tag-help) |
44333
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
103 (define-key map "\C-c/" 'sgml-close-tag) |
108541
ce09b34d4a43
Add TeX open-block and close-block keybindings to SGML, and vice versa.
Chong Yidong <cyd@stupidchicken.com>
parents:
106947
diff
changeset
|
104 |
ce09b34d4a43
Add TeX open-block and close-block keybindings to SGML, and vice versa.
Chong Yidong <cyd@stupidchicken.com>
parents:
106947
diff
changeset
|
105 ;; Redundant keybindings, for consistency with TeX mode. |
ce09b34d4a43
Add TeX open-block and close-block keybindings to SGML, and vice versa.
Chong Yidong <cyd@stupidchicken.com>
parents:
106947
diff
changeset
|
106 (define-key map "\C-c\C-o" 'sgml-tag) |
ce09b34d4a43
Add TeX open-block and close-block keybindings to SGML, and vice versa.
Chong Yidong <cyd@stupidchicken.com>
parents:
106947
diff
changeset
|
107 (define-key map "\C-c\C-e" 'sgml-close-tag) |
ce09b34d4a43
Add TeX open-block and close-block keybindings to SGML, and vice versa.
Chong Yidong <cyd@stupidchicken.com>
parents:
106947
diff
changeset
|
108 |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
109 (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
|
110 (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
|
111 (when sgml-quick-keys |
13a1b8cf5135
added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents:
38431
diff
changeset
|
112 (define-key map "&" 'sgml-name-char) |
13a1b8cf5135
added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents:
38431
diff
changeset
|
113 (define-key map "<" 'sgml-tag) |
13a1b8cf5135
added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents:
38431
diff
changeset
|
114 (define-key map " " 'sgml-auto-attributes) |
13a1b8cf5135
added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents:
38431
diff
changeset
|
115 (define-key map ">" 'sgml-maybe-end-tag) |
13a1b8cf5135
added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents:
38431
diff
changeset
|
116 (when (memq ?\" sgml-specials) |
13a1b8cf5135
added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents:
38431
diff
changeset
|
117 (define-key map "\"" 'sgml-name-self)) |
13a1b8cf5135
added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents:
38431
diff
changeset
|
118 (when (memq ?' sgml-specials) |
13a1b8cf5135
added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents:
38431
diff
changeset
|
119 (define-key map "'" 'sgml-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
|
120 (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
|
121 (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
|
122 (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
|
123 (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
|
124 (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
|
125 (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
|
126 (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
|
127 '("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
|
128 (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
|
129 '("Toggle Tag Visibility" . sgml-tags-invisible)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
130 (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
|
131 '("Describe Tag" . sgml-tag-help)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
132 (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
|
133 '("Delete Tag" . sgml-delete-tag)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
134 (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
|
135 '("Forward Tag" . sgml-skip-tag-forward)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
136 (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
|
137 '("Backward Tag" . sgml-skip-tag-backward)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
138 (define-key menu-map [sgml-attributes] |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
139 '("Insert Attributes" . sgml-attributes)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
140 (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
|
141 map) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
142 "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
|
143 |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
144 (defun sgml-make-syntax-table (specials) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
145 (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
|
146 (modify-syntax-entry ?< "(>" table) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
147 (modify-syntax-entry ?> ")<" table) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
148 (modify-syntax-entry ?: "_" table) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
149 (modify-syntax-entry ?_ "_" table) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
150 (modify-syntax-entry ?. "_" table) |
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 ?- "_ 1234" table)) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
153 (if (memq ?\" specials) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
154 (modify-syntax-entry ?\" "\"\"" table)) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
155 (if (memq ?' specials) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
156 (modify-syntax-entry ?\' "\"'" table)) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
157 table)) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
158 |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
159 (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
|
160 "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
|
161 |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
162 (defconst sgml-tag-syntax-table |
87684
9349c39d2ae0
* testmodes/sgml-mode.el (sgml-tag-syntax-table): Initialize this
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
87567
diff
changeset
|
163 (let ((table (sgml-make-syntax-table sgml-specials))) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
164 (dolist (char '(?\( ?\) ?\{ ?\} ?\[ ?\] ?$ ?% ?& ?* ?+ ?/)) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
165 (modify-syntax-entry char "." table)) |
98237
fc3f7f475220
(sgml-tag-syntax-table): Remove prefix
Martin Rudalics <rudalics@gmx.at>
parents:
96509
diff
changeset
|
166 (unless (memq ?' sgml-specials) |
fc3f7f475220
(sgml-tag-syntax-table): Remove prefix
Martin Rudalics <rudalics@gmx.at>
parents:
96509
diff
changeset
|
167 ;; Avoid that skipping a tag backwards skips any "'" prefixing it. |
fc3f7f475220
(sgml-tag-syntax-table): Remove prefix
Martin Rudalics <rudalics@gmx.at>
parents:
96509
diff
changeset
|
168 (modify-syntax-entry ?' "w" table)) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
169 table) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
170 "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
|
171 |
17432
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
172 (defcustom sgml-name-8bit-mode nil |
80889
8938fa90afdb
(sgml-value): Fix handling of attributes which can take any number of values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80876
diff
changeset
|
173 "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
|
174 :type 'boolean |
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
175 :group 'sgml) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
176 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
177 (defvar sgml-char-names |
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 nil nil nil nil nil nil |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
180 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
|
181 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
|
182 "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
|
183 "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
|
184 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
|
185 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
|
186 "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
|
187 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
|
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 "lsqb" nil "rsqb" "uarr" "lowbar" |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
190 "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
|
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 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
|
193 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
|
194 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
|
195 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
|
196 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
|
197 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
|
198 "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
|
199 "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
|
200 "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
|
201 "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
|
202 "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
|
203 "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
|
204 "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
|
205 "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
|
206 "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
|
207 "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
|
208 "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
|
209 "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
|
210 "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
|
211 |
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
|
212 (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
|
213 |
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 (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
|
215 (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
|
216 (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
|
217 elt) |
88415
8fb7bc8f8acc
(sgml-mode-map): Use encode-char instead
Kenichi Handa <handa@m17n.org>
parents:
40624
diff
changeset
|
218 (while (< i 128) |
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
|
219 (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
|
220 (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
|
221 (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
|
222 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
|
223 "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
|
224 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
|
225 |
25052
d2a4359531e0
(sgml-validate-command): Use nsgmls.
Dave Love <fx@gnu.org>
parents:
24463
diff
changeset
|
226 ;; 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
|
227 ;; 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
|
228 ;; 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
|
229 ;; The -s option suppresses output. |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
230 |
25052
d2a4359531e0
(sgml-validate-command): Use nsgmls.
Dave Love <fx@gnu.org>
parents:
24463
diff
changeset
|
231 (defcustom sgml-validate-command "nsgmls -s" ; replaced old `sgmls' |
80889
8938fa90afdb
(sgml-value): Fix handling of attributes which can take any number of values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80876
diff
changeset
|
232 "The command to validate an SGML document. |
809 | 233 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
|
234 separated by a space." |
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
235 :type 'string |
25175 | 236 :version "21.1" |
17432
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
237 :group 'sgml) |
809 | 238 |
239 (defvar sgml-saved-validate-command nil | |
240 "The command last used to validate in this buffer.") | |
241 | |
38068
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
242 ;; 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
|
243 ;; 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
|
244 (defcustom sgml-slash-distance 1000 |
80889
8938fa90afdb
(sgml-value): Fix handling of attributes which can take any number of values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80876
diff
changeset
|
245 "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
|
246 :type '(choice (const nil) integer) |
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
247 :group 'sgml) |
809 | 248 |
50955
7a718ea39fba
(sgml-namespace-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49153
diff
changeset
|
249 (defconst sgml-namespace-re "[_[:alpha:]][-_.[:alnum:]]*") |
44241
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
250 (defconst sgml-name-re "[_:[:alpha:]][-_.:[:alnum:]]*") |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
251 (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
|
252 (defconst sgml-attrs-re "\\(?:[^\"'/><]\\|\"[^\"]*\"\\|'[^']*'\\)*") |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
253 (defconst sgml-start-tag-regex (concat "<" sgml-name-re sgml-attrs-re) |
809 | 254 "Regular expression that matches a non-empty start tag. |
17551 | 255 Any terminating `>' or `/' is not matched.") |
809 | 256 |
63226
33e854825b44
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-390
Miles Bader <miles@gnu.org>
parents:
62809
diff
changeset
|
257 (defface sgml-namespace |
50955
7a718ea39fba
(sgml-namespace-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49153
diff
changeset
|
258 '((t (:inherit font-lock-builtin-face))) |
62809
e38d2ae61b0a
(sgml-namespace-face): Specify customization group.
Lute Kamstra <lute@gnu.org>
parents:
61014
diff
changeset
|
259 "`sgml-mode' face used to highlight the namespace part of identifiers." |
e38d2ae61b0a
(sgml-namespace-face): Specify customization group.
Lute Kamstra <lute@gnu.org>
parents:
61014
diff
changeset
|
260 :group 'sgml) |
63226
33e854825b44
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-390
Miles Bader <miles@gnu.org>
parents:
62809
diff
changeset
|
261 (defvar sgml-namespace-face 'sgml-namespace) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
262 |
21780
5dc3fe7cd300
(sgml-font-lock-keywords-1): Copy initialization from sgml-font-lock-keywords.
Richard M. Stallman <rms@gnu.org>
parents:
20922
diff
changeset
|
263 ;; internal |
5dc3fe7cd300
(sgml-font-lock-keywords-1): Copy initialization from sgml-font-lock-keywords.
Richard M. Stallman <rms@gnu.org>
parents:
20922
diff
changeset
|
264 (defconst sgml-font-lock-keywords-1 |
44241
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
265 `((,(concat "<\\([!?]" sgml-name-re "\\)") 1 font-lock-keyword-face) |
50955
7a718ea39fba
(sgml-namespace-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49153
diff
changeset
|
266 ;; We could use the simpler "\\(" sgml-namespace-re ":\\)?" instead, |
7a718ea39fba
(sgml-namespace-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49153
diff
changeset
|
267 ;; but it would cause a bit more backtracking in the re-matcher. |
7a718ea39fba
(sgml-namespace-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49153
diff
changeset
|
268 (,(concat "</?\\(" sgml-namespace-re "\\)\\(?::\\(" sgml-name-re "\\)\\)?") |
7a718ea39fba
(sgml-namespace-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49153
diff
changeset
|
269 (1 (if (match-end 2) sgml-namespace-face font-lock-function-name-face)) |
7a718ea39fba
(sgml-namespace-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49153
diff
changeset
|
270 (2 font-lock-function-name-face nil t)) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
271 ;; FIXME: this doesn't cover the variables using a default value. |
74397
429f18443ca0
(sgml-font-lock-keywords-1): Fix pathological O(n^2) regexp-search by
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70823
diff
changeset
|
272 ;; The first shy-group is an important anchor: it prevents an O(n^2) |
429f18443ca0
(sgml-font-lock-keywords-1): Fix pathological O(n^2) regexp-search by
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70823
diff
changeset
|
273 ;; pathological case where we otherwise keep retrying a failing match |
429f18443ca0
(sgml-font-lock-keywords-1): Fix pathological O(n^2) regexp-search by
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70823
diff
changeset
|
274 ;; against a very long word at every possible position within the word. |
429f18443ca0
(sgml-font-lock-keywords-1): Fix pathological O(n^2) regexp-search by
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
70823
diff
changeset
|
275 (,(concat "\\(?:^\\|[ \t]\\)\\(" sgml-namespace-re "\\)\\(?::\\(" |
50955
7a718ea39fba
(sgml-namespace-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49153
diff
changeset
|
276 sgml-name-re "\\)\\)?=[\"']") |
7a718ea39fba
(sgml-namespace-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49153
diff
changeset
|
277 (1 (if (match-end 2) sgml-namespace-face font-lock-variable-name-face)) |
7a718ea39fba
(sgml-namespace-re): New const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49153
diff
changeset
|
278 (2 font-lock-variable-name-face nil t)) |
44241
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
279 (,(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
|
280 |
40320
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
281 (defconst sgml-font-lock-keywords-2 |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
282 (append |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
283 sgml-font-lock-keywords-1 |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
284 '((eval |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
285 . (cons (concat "<" |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
286 (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
|
287 "\\([ \t][^>]*\\)?>\\([^<]+\\)</\\1>") |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
288 '(3 (cdr (assoc-string (match-string 1) sgml-tag-face-alist t)) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
289 prepend)))))) |
21780
5dc3fe7cd300
(sgml-font-lock-keywords-1): Copy initialization from sgml-font-lock-keywords.
Richard M. Stallman <rms@gnu.org>
parents:
20922
diff
changeset
|
290 |
5dc3fe7cd300
(sgml-font-lock-keywords-1): Copy initialization from sgml-font-lock-keywords.
Richard M. Stallman <rms@gnu.org>
parents:
20922
diff
changeset
|
291 ;; 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
|
292 ;; 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
|
293 (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
|
294 "*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
|
295 |
40320
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
296 (defvar sgml-font-lock-syntactic-keywords |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
297 ;; 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
|
298 ;; comments recognized when `sgml-specials' includes ?-. |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
299 ;; FIXME: beware of <!--> blabla <!--> !! |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
300 '(("\\(<\\)!--" (1 "< b")) |
92748
ef656c281e1e
(sgml-font-lock-syntactic-keywords): Mark " outside of tags as punctuation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92148
diff
changeset
|
301 ("--[ \t\n]*\\(>\\)" (1 "> b")) |
ef656c281e1e
(sgml-font-lock-syntactic-keywords): Mark " outside of tags as punctuation.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92148
diff
changeset
|
302 ;; Double quotes outside of tags should not introduce strings. |
96509
0b35188a36dd
(sgml-font-lock-syntactic-keywords):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94670
diff
changeset
|
303 ;; Be careful to call `syntax-ppss' on a position before the one we're |
0b35188a36dd
(sgml-font-lock-syntactic-keywords):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94670
diff
changeset
|
304 ;; going to change, so as not to need to flush the data we just computed. |
0b35188a36dd
(sgml-font-lock-syntactic-keywords):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94670
diff
changeset
|
305 ("\"" (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0)))) |
0b35188a36dd
(sgml-font-lock-syntactic-keywords):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94670
diff
changeset
|
306 (goto-char (match-end 0))) |
0b35188a36dd
(sgml-font-lock-syntactic-keywords):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94670
diff
changeset
|
307 ".")))) |
40320
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
308 "Syntactic keywords for `sgml-mode'.") |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
309 |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
310 ;; internal |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
311 (defvar sgml-face-tag-alist () |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
312 "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
|
313 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
314 (defvar sgml-tag-face-alist () |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
315 "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
|
316 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
|
317 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
|
318 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
319 (defvar sgml-display-text () |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
320 "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
|
321 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
322 ;; internal |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
323 (defvar sgml-tags-invisible nil) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
324 |
17432
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
325 (defcustom sgml-tag-alist |
14270
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
326 '(("![" ("ignore" t) ("include" t)) |
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
327 ("!attlist") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
328 ("!doctype") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
329 ("!element") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
330 ("!entity")) |
80889
8938fa90afdb
(sgml-value): Fix handling of attributes which can take any number of values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80876
diff
changeset
|
331 "Alist of tag names for completing read and insertion rules. |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
332 This alist is made up as |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
333 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
334 ((\"tag\" . TAGRULE) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
335 ...) |
809 | 336 |
44459
25c3c51b0375
(sgml-tag-alist): Doc fix.
Mike Williams <mdub@bigfoot.com>
parents:
44443
diff
changeset
|
337 TAGRULE is a list of optionally t (no endtag) or `\\n' (separate endtag by |
25c3c51b0375
(sgml-tag-alist): Doc fix.
Mike Williams <mdub@bigfoot.com>
parents:
44443
diff
changeset
|
338 newlines) or a skeleton with nil, t or `\\n' in place of the interactor |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
339 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
|
340 attribute alist. |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
341 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
342 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
|
343 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
344 ((\"attribute\" . ATTRIBUTERULE) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
345 ...) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
346 |
44459
25c3c51b0375
(sgml-tag-alist): Doc fix.
Mike Williams <mdub@bigfoot.com>
parents:
44443
diff
changeset
|
347 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
|
348 an optional alist of possible values." |
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
349 :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
|
350 (repeat :tag "Tag Rule" sexp))) |
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
351 :group 'sgml) |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
352 (put 'sgml-tag-alist 'risky-local-variable t) |
809 | 353 |
17432
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
354 (defcustom sgml-tag-help |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
355 '(("!" . "Empty declaration for comment") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
356 ("![" . "Embed declarations with parser directive") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
357 ("!attlist" . "Tag attributes declaration") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
358 ("!doctype" . "Document type (DTD) declaration") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
359 ("!element" . "Tag declaration") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
360 ("!entity" . "Entity (macro) declaration")) |
80889
8938fa90afdb
(sgml-value): Fix handling of attributes which can take any number of values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80876
diff
changeset
|
361 "Alist of tag name and short description." |
17432
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
362 :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
|
363 (string :tag "Description"))) |
5d2e0051fe39
Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17309
diff
changeset
|
364 :group 'sgml) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
365 |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
366 (defcustom sgml-xml-mode nil |
80889
8938fa90afdb
(sgml-value): Fix handling of attributes which can take any number of values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80876
diff
changeset
|
367 "When non-nil, tag insertion functions will be XML-compliant. |
8938fa90afdb
(sgml-value): Fix handling of attributes which can take any number of values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80876
diff
changeset
|
368 It is set to be buffer-local when the file has |
60521 | 369 a DOCTYPE or an XML declaration." |
40377
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
370 :type 'boolean |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59519
diff
changeset
|
371 :version "22.1" |
40377
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
372 :group 'sgml) |
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
373 |
40392
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
374 (defvar sgml-empty-tags nil |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
375 "List of tags whose !ELEMENT definition says EMPTY.") |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
376 |
44241
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
377 (defvar sgml-unclosed-tags nil |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
378 "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
|
379 |
40377
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
380 (defun sgml-xml-guess () |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
381 "Guess whether the current buffer is XML. Return non-nil if so." |
40377
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
382 (save-excursion |
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
383 (goto-char (point-min)) |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
384 (or (string= "xml" (file-name-extension (or buffer-file-name ""))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
385 (looking-at "\\s-*<\\?xml") |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
386 (when (re-search-forward |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
387 (eval-when-compile |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
388 (mapconcat 'identity |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
389 '("<!DOCTYPE" "\\(\\w+\\)" "\\(\\w+\\)" |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
390 "\"\\([^\"]+\\)\"" "\"\\([^\"]+\\)\"") |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
391 "\\s-+")) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
392 nil t) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
393 (string-match "X\\(HT\\)?ML" (match-string 3)))))) |
40377
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
394 |
23726 | 395 (defvar v2) ; free for skeleton |
396 | |
44443
9e6f2afa9f19
(sgml-comment-indent-new-line): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44388
diff
changeset
|
397 (defun sgml-comment-indent-new-line (&optional soft) |
9e6f2afa9f19
(sgml-comment-indent-new-line): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44388
diff
changeset
|
398 (let ((comment-start "-- ") |
9e6f2afa9f19
(sgml-comment-indent-new-line): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44388
diff
changeset
|
399 (comment-start-skip "\\(<!\\)?--[ \t]*") |
9e6f2afa9f19
(sgml-comment-indent-new-line): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44388
diff
changeset
|
400 (comment-end " --") |
9e6f2afa9f19
(sgml-comment-indent-new-line): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44388
diff
changeset
|
401 (comment-style 'plain)) |
9e6f2afa9f19
(sgml-comment-indent-new-line): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44388
diff
changeset
|
402 (comment-indent-new-line soft))) |
9e6f2afa9f19
(sgml-comment-indent-new-line): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44388
diff
changeset
|
403 |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
404 (defun sgml-mode-facemenu-add-face-function (face end) |
105821
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
405 (let ((tag-face (cdr (assq face sgml-face-tag-alist)))) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
406 (cond (tag-face |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
407 (setq tag-face (funcall skeleton-transformation-function tag-face)) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
408 (setq facemenu-end-add-face (concat "</" tag-face ">")) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
409 (concat "<" tag-face ">")) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
410 ((and (consp face) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
411 (consp (car face)) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
412 (null (cdr face)) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
413 (memq (caar face) '(:foreground :background))) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
414 (setq facemenu-end-add-face "</span>") |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
415 (format "<span style=\"%s:%s\">" |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
416 (if (eq (caar face) :foreground) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
417 "color" |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
418 "background-color") |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
419 (cadr (car face)))) |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
420 (t |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
421 (error "Face not configured for %s mode" |
18698b6aca31
* textmodes/sgml-mode.el (sgml-mode-facemenu-add-face-function):
Chong Yidong <cyd@stupidchicken.com>
parents:
105737
diff
changeset
|
422 (format-mode-line mode-name)))))) |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
423 |
59519
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
424 (defun sgml-fill-nobreak () |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
425 ;; Don't break between a tag name and its first argument. |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
426 (save-excursion |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
427 (skip-chars-backward " \t") |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
428 (and (not (zerop (skip-syntax-backward "w_"))) |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
429 (skip-chars-backward "/?!") |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
430 (eq (char-before) ?<)))) |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
431 |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
432 ;;;###autoload |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
433 (define-derived-mode sgml-mode text-mode '(sgml-xml-mode "XML" "SGML") |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
434 "Major mode for editing SGML documents. |
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
435 Makes > match <. |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
436 Keys <, &, SPC within <>, \", / and ' can be electric depending on |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
437 `sgml-quick-keys'. |
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
438 |
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
439 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
|
440 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
|
441 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
|
442 |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
443 If you like upcased tags, put (setq sgml-transformation-function 'upcase) |
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
444 in your `.emacs' file. |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
445 |
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
446 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
|
447 |
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
448 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
|
449 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
|
450 \\{sgml-mode-map}" |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
451 (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
|
452 (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
|
453 ;;(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
|
454 ;; 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
|
455 ;; 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
|
456 ;; 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
|
457 (set (make-local-variable 'paragraph-start) (concat "[ \t]*$\\|\ |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
458 \[ \t]*</?\\(" sgml-name-re sgml-attrs-re "\\)?>")) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
459 (set (make-local-variable 'paragraph-separate) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
460 (concat paragraph-start "$")) |
40377
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
461 (set (make-local-variable 'adaptive-fill-regexp) "[ \t]*") |
59519
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
462 (add-hook 'fill-nobreak-predicate 'sgml-fill-nobreak nil t) |
44293
a1bba2ef8c34
(sgml-mode): Set indent-line-function to sgml-indent-line.
Mike Williams <mdub@bigfoot.com>
parents:
44286
diff
changeset
|
463 (set (make-local-variable 'indent-line-function) 'sgml-indent-line) |
40377
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
464 (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
|
465 (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
|
466 (set (make-local-variable 'comment-indent-function) 'sgml-comment-indent) |
44443
9e6f2afa9f19
(sgml-comment-indent-new-line): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44388
diff
changeset
|
467 (set (make-local-variable 'comment-line-break-function) |
9e6f2afa9f19
(sgml-comment-indent-new-line): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44388
diff
changeset
|
468 'sgml-comment-indent-new-line) |
40377
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
469 (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
|
470 '((completion-ignore-case t))) |
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
471 (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
|
472 (lambda () |
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
473 (or (eolp) |
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
474 (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
|
475 (newline-and-indent)))) |
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
476 (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
|
477 '((sgml-font-lock-keywords |
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
478 sgml-font-lock-keywords-1 |
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
479 sgml-font-lock-keywords-2) |
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
480 nil t nil nil |
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
481 (font-lock-syntactic-keywords |
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
482 . sgml-font-lock-syntactic-keywords))) |
ea7ef845ccf3
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents:
40350
diff
changeset
|
483 (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
|
484 'sgml-mode-facemenu-add-face-function) |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
485 (set (make-local-variable 'sgml-xml-mode) (sgml-xml-guess)) |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
486 (if sgml-xml-mode |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
487 () |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
488 (set (make-local-variable 'skeleton-transformation-function) |
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
489 sgml-transformation-function)) |
36609
8e1755c3dd2b
(sgml-mode-common): Correct value of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27683
diff
changeset
|
490 ;; 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
|
491 ;; recognized. |
80120
09b5c9664c42
(sgml-mode): Fix comment syntax.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79719
diff
changeset
|
492 ;; I can't find a clear description of SGML/XML comments, but it seems that |
09b5c9664c42
(sgml-mode): Fix comment syntax.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79719
diff
changeset
|
493 ;; the only reliable ones are <!-- ... --> although it's not clear what |
09b5c9664c42
(sgml-mode): Fix comment syntax.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79719
diff
changeset
|
494 ;; "..." can contain. It used to accept -- ... -- as well, but that was |
09b5c9664c42
(sgml-mode): Fix comment syntax.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79719
diff
changeset
|
495 ;; apparently a mistake. |
09b5c9664c42
(sgml-mode): Fix comment syntax.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79719
diff
changeset
|
496 (set (make-local-variable 'comment-start-skip) "<!--[ \t]*") |
09b5c9664c42
(sgml-mode): Fix comment syntax.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79719
diff
changeset
|
497 (set (make-local-variable 'comment-end-skip) "[ \t]*--[ \t\n]*>") |
57718
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
498 ;; This definition has an HTML leaning but probably fits well for other modes. |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
499 (setq imenu-generic-expression |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
500 `((nil |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
501 ,(concat "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\(" |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
502 sgml-name-re "\\)") |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
503 2) |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
504 ("Id" |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
505 ,(concat "<[^>]+[ \t\n]+[Ii][Dd]=\\(['\"]" |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
506 (if sgml-xml-mode "" "?") |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
507 "\\)\\(" sgml-name-re "\\)\\1") |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
508 2) |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
509 ("Name" |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
510 ,(concat "<[^>]+[ \t\n]+[Nn][Aa][Mm][Ee]=\\(['\"]" |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
511 (if sgml-xml-mode "" "?") |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
512 "\\)\\(" sgml-name-re "\\)\\1") |
e60d53125cf2
(sgml-mode): Fix imenu-generic-expression and add "Id" and "Name" submenus to it.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
52401
diff
changeset
|
513 2)))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
514 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
515 (defun sgml-comment-indent () |
36609
8e1755c3dd2b
(sgml-mode-common): Correct value of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27683
diff
changeset
|
516 (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
|
517 |
809 | 518 (defun sgml-slash (arg) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
519 "Insert ARG slash characters. |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
520 Behaves electrically if `sgml-quick-keys' is non-nil." |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
521 (interactive "p") |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
522 (cond |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
523 ((not (and (eq (char-before) ?<) (= arg 1))) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
524 (sgml-slash-matching arg)) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
525 ((eq sgml-quick-keys 'indent) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
526 (insert-char ?/ 1) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
527 (indent-according-to-mode)) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
528 ((eq sgml-quick-keys 'close) |
108765
d835100c3e8b
Replace Lisp calls to delete-backward-char by delete-char.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108541
diff
changeset
|
529 (delete-char -1) |
44333
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
530 (sgml-close-tag)) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
531 (t |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
532 (sgml-slash-matching arg)))) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
533 |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
534 (defun sgml-slash-matching (arg) |
17551 | 535 "Insert `/' and display any previous matching `/'. |
536 Two `/'s are treated as matching if the first `/' ends a net-enabling | |
537 start tag, and the second `/' is the corresponding null end tag." | |
809 | 538 (interactive "p") |
539 (insert-char ?/ arg) | |
540 (if (> arg 0) | |
541 (let ((oldpos (point)) | |
542 (blinkpos) | |
543 (level 0)) | |
544 (save-excursion | |
545 (save-restriction | |
546 (if sgml-slash-distance | |
547 (narrow-to-region (max (point-min) | |
548 (- (point) sgml-slash-distance)) | |
549 oldpos)) | |
550 (if (and (re-search-backward sgml-start-tag-regex (point-min) t) | |
551 (eq (match-end 0) (1- oldpos))) | |
552 () | |
553 (goto-char (1- oldpos)) | |
554 (while (and (not blinkpos) | |
555 (search-backward "/" (point-min) t)) | |
556 (let ((tagend (save-excursion | |
557 (if (re-search-backward sgml-start-tag-regex | |
558 (point-min) t) | |
559 (match-end 0) | |
560 nil)))) | |
561 (if (eq tagend (point)) | |
562 (if (eq level 0) | |
563 (setq blinkpos (point)) | |
564 (setq level (1- level))) | |
565 (setq level (1+ level))))))) | |
40343
25129ef47b45
some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents:
40320
diff
changeset
|
566 (when blinkpos |
25129ef47b45
some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents:
40320
diff
changeset
|
567 (goto-char blinkpos) |
25129ef47b45
some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents:
40320
diff
changeset
|
568 (if (pos-visible-in-window-p) |
25129ef47b45
some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents:
40320
diff
changeset
|
569 (sit-for 1) |
25129ef47b45
some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents:
40320
diff
changeset
|
570 (message "Matches %s" |
25129ef47b45
some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents:
40320
diff
changeset
|
571 (buffer-substring (line-beginning-position) |
25129ef47b45
some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents:
40320
diff
changeset
|
572 (1+ blinkpos))))))))) |
809 | 573 |
43692
568974ab1796
Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43589
diff
changeset
|
574 ;; 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
|
575 ;; 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
|
576 ;; 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
|
577 (defun sgml-name-char (&optional char) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
578 "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
|
579 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
|
580 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
|
581 encoded keyboard operation." |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
582 (interactive "*") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
583 (insert ?&) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
584 (or char |
17500
e8d7c7e2acab
(sgml-name-char): Ask user with a prompt.
Richard M. Stallman <rms@gnu.org>
parents:
17491
diff
changeset
|
585 (setq char (read-quoted-char "Enter char or octal number"))) |
108765
d835100c3e8b
Replace Lisp calls to delete-backward-char by delete-char.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108541
diff
changeset
|
586 (delete-char -1) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
587 (insert char) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
588 (undo-boundary) |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
589 (sgml-namify-char)) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
590 |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
591 (defun sgml-namify-char () |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
592 "Change the char before point into its `&name;' equivalent. |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
593 Uses `sgml-char-names'." |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
594 (interactive) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
595 (let* ((char (char-before)) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
596 (name |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
597 (cond |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
598 ((null char) (error "No char before point")) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
599 ((< char 256) (or (aref sgml-char-names char) char)) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
600 ((aref sgml-char-names-table char)) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
601 ((encode-char char 'ucs))))) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
602 (if (not name) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
603 (error "Don't know the name of `%c'" char) |
108765
d835100c3e8b
Replace Lisp calls to delete-backward-char by delete-char.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108541
diff
changeset
|
604 (delete-char -1) |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
605 (insert (format (if (numberp name) "&#%d;" "&%s;") name))))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
606 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
607 (defun sgml-name-self () |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
608 "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
|
609 (interactive "*") |
101003
cc189e8cf211
Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
610 (sgml-name-char last-command-event)) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
611 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
612 (defun sgml-maybe-name-self () |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
613 "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
|
614 (interactive "*") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
615 (if sgml-name-8bit-mode |
106947
938f7da4579e
Fix sgml-maybe-name-self (Bug#5380).
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
616 (sgml-name-char last-command-event) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
617 (self-insert-command 1))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
618 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
619 (defun sgml-name-8bit-mode () |
43692
568974ab1796
Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43589
diff
changeset
|
620 "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
|
621 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
|
622 (interactive) |
17545
c67787f92aea
(sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents:
17530
diff
changeset
|
623 (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
|
624 (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
|
625 (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
|
626 |
17551 | 627 ;; When an element of a skeleton is a string "str", it is passed |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
628 ;; through `skeleton-transformation-function' and inserted. |
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
629 ;; If "str" is to be inserted literally, one should obtain it as |
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
630 ;; the return value of a function, e.g. (identity "str"). |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
631 |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
632 (defvar sgml-tag-last nil) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
633 (defvar sgml-tag-history nil) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
634 (define-skeleton sgml-tag |
17551 | 635 "Prompt for a tag and insert it, optionally with attributes. |
636 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
|
637 If you like tags and attributes in uppercase do \\[set-variable] |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
638 `skeleton-transformation-function' RET `upcase' RET, or put this |
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
639 in your `.emacs': |
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
640 (setq sgml-transformation-function 'upcase)" |
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
641 (funcall (or skeleton-transformation-function 'identity) |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
642 (setq sgml-tag-last |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
643 (completing-read |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
644 (if (> (length sgml-tag-last) 0) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
645 (format "Tag (default %s): " sgml-tag-last) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
646 "Tag: ") |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
647 sgml-tag-alist nil nil nil 'sgml-tag-history sgml-tag-last))) |
36609
8e1755c3dd2b
(sgml-mode-common): Correct value of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
27683
diff
changeset
|
648 ?< str | |
17545
c67787f92aea
(sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents:
17530
diff
changeset
|
649 (("") -1 '(undo-boundary) (identity "<")) | ; see comment above |
40392
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
650 `(("") '(setq v2 (sgml-attributes ,str t)) ?> |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
651 (cond |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
652 ((string= "![" ,str) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
653 (backward-char) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
654 '(("") " [ " _ " ]]")) |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
655 ((and (eq v2 t) sgml-xml-mode (member ,str sgml-empty-tags)) |
60521 | 656 '(("") -1 " />")) |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
657 ((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
|
658 nil) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
659 ((symbolp v2) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
660 ;; 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
|
661 ;; 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
|
662 (if (eq v2 t) (setq v2 nil)) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
663 ;; We use `identity' to prevent skeleton from passing |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
664 ;; `str' through `skeleton-transformation-function' a second time. |
40392
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
665 '(("") v2 _ v2 "</" (identity ',str) ?>)) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
666 ((eq (car v2) t) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
667 (cons '("") (cdr v2))) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
668 (t |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
669 (append '(("") (car v2)) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
670 (cdr v2) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
671 '(resume: (car v2) _ "</" (identity ',str) ?>)))))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
672 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
673 (autoload 'skeleton-read "skeleton") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
674 |
17545
c67787f92aea
(sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents:
17530
diff
changeset
|
675 (defun sgml-attributes (tag &optional quiet) |
17551 | 676 "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
|
677 |
17551 | 678 Completion and configuration of TAG are done according to `sgml-tag-alist'. |
679 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
|
680 (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
|
681 (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
|
682 (if tag |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
683 (let ((completion-ignore-case t) |
17545
c67787f92aea
(sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents:
17530
diff
changeset
|
684 (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
|
685 car attribute i) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
686 (if (or (symbolp (car alist)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
687 (symbolp (car (car alist)))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
688 (setq car (car alist) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
689 alist (cdr alist))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
690 (or quiet |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
691 (message "No attributes configured.")) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
692 (if (stringp (car alist)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
693 (progn |
64058
7e00d33823d3
(sgml): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63521
diff
changeset
|
694 (insert (if (eq (preceding-char) ?\s) "" ?\s) |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
695 (funcall skeleton-transformation-function (car alist))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
696 (sgml-value alist)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
697 (setq i (length alist)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
698 (while (> i 0) |
64058
7e00d33823d3
(sgml): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63521
diff
changeset
|
699 (insert ?\s) |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
700 (insert (funcall skeleton-transformation-function |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
701 (setq attribute |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
702 (skeleton-read '(completing-read |
17545
c67787f92aea
(sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents:
17530
diff
changeset
|
703 "Attribute: " |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
704 alist))))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
705 (if (string= "" attribute) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
706 (setq i 0) |
20922
3ae81bc17b19
(sgml-mode-common): Downcase key for
Dave Love <fx@gnu.org>
parents:
20394
diff
changeset
|
707 (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
|
708 (setq i (1- i)))) |
64058
7e00d33823d3
(sgml): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63521
diff
changeset
|
709 (if (eq (preceding-char) ?\s) |
108765
d835100c3e8b
Replace Lisp calls to delete-backward-char by delete-char.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108541
diff
changeset
|
710 (delete-char -1))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
711 car))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
712 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
713 (defun sgml-auto-attributes (arg) |
17551 | 714 "Self insert the character typed; at top level of tag, prompt for attributes. |
715 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
|
716 (interactive "*P") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
717 (let ((point (point)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
718 tag) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
719 (if (or arg |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
720 (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
|
721 (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
|
722 (eq (aref tag 0) ?/)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
723 (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
|
724 (sgml-attributes tag) |
101003
cc189e8cf211
Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
725 (setq last-command-event ?\s) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
726 (or (> (point) point) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
727 (self-insert-command 1))))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
728 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
729 (defun sgml-tag-help (&optional tag) |
17551 | 730 "Display description of tag TAG. If TAG is omitted, use the tag at point." |
105662
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
731 (interactive |
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
732 (list (let ((def (save-excursion |
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
733 (if (eq (following-char) ?<) (forward-char)) |
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
734 (sgml-beginning-of-tag)))) |
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
735 (completing-read (if def |
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
736 (format "Tag (default %s): " def) |
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
737 "Tag: ") |
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
738 sgml-tag-alist nil nil nil |
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
739 'sgml-tag-history def)))) |
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
740 (or (and tag (> (length tag) 0)) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
741 (save-excursion |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
742 (if (eq (following-char) ?<) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
743 (forward-char)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
744 (setq tag (sgml-beginning-of-tag)))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
745 (or (stringp tag) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
746 (error "No tag selected")) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
747 (setq tag (downcase tag)) |
14328
5d0e329a44d8
(sgml-tag-help): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents:
14270
diff
changeset
|
748 (message "%s" |
20922
3ae81bc17b19
(sgml-mode-common): Downcase key for
Dave Love <fx@gnu.org>
parents:
20394
diff
changeset
|
749 (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
|
750 (and (eq (aref tag 0) ?/) |
20922
3ae81bc17b19
(sgml-mode-common): Downcase key for
Dave Love <fx@gnu.org>
parents:
20394
diff
changeset
|
751 (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
|
752 "No description available"))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
753 |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
754 (defun sgml-maybe-end-tag (&optional arg) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
755 "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
|
756 (interactive "P") |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
757 (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
|
758 (self-insert-command (prefix-numeric-value arg)) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
759 (sgml-name-self))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
760 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
761 (defun sgml-skip-tag-backward (arg) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
762 "Skip to beginning of tag or matching opening tag if present. |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
763 With prefix argument ARG, repeat this ARG times. |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
764 Return non-nil if we skipped over matched tags." |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
765 (interactive "p") |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
766 ;; FIXME: use sgml-get-context or something similar. |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
767 (let ((return t)) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
768 (while (>= arg 1) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
769 (search-backward "<" nil t) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
770 (if (looking-at "</\\([^ \n\t>]+\\)") |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
771 ;; end tag, skip any nested pairs |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
772 (let ((case-fold-search t) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
773 (re (concat "</?" (regexp-quote (match-string 1)) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
774 ;; Ignore empty tags like <foo/>. |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
775 "\\([^>]*[^/>]\\)?>"))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
776 (while (and (re-search-backward re nil t) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
777 (eq (char-after (1+ (point))) ?/)) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
778 (forward-char 1) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
779 (sgml-skip-tag-backward 1))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
780 (setq return nil)) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
781 (setq arg (1- arg))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
782 return)) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
783 |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
784 (defvar sgml-electric-tag-pair-overlays nil) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
785 (defvar sgml-electric-tag-pair-timer nil) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
786 |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
787 (defun sgml-electric-tag-pair-before-change-function (beg end) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
788 (condition-case err |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
789 (save-excursion |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
790 (goto-char end) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
791 (skip-chars-backward "[:alnum:]-_.:") |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
792 (if (and ;; (<= (point) beg) ; This poses problems for downcase-word. |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
793 (or (eq (char-before) ?<) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
794 (and (eq (char-before) ?/) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
795 (eq (char-before (1- (point))) ?<))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
796 (null (get-char-property (point) 'text-clones))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
797 (let* ((endp (eq (char-before) ?/)) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
798 (cl-start (point)) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
799 (cl-end (progn (skip-chars-forward "[:alnum:]-_.:") (point))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
800 (match |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
801 (if endp |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
802 (when (sgml-skip-tag-backward 1) (forward-char 1) t) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
803 (with-syntax-table sgml-tag-syntax-table |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
804 (up-list -1) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
805 (when (sgml-skip-tag-forward 1) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
806 (backward-sexp 1) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
807 (forward-char 2) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
808 t)))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
809 (clones (get-char-property (point) 'text-clones))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
810 (when (and match |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
811 (/= cl-end cl-start) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
812 (equal (buffer-substring cl-start cl-end) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
813 (buffer-substring (point) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
814 (save-excursion |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
815 (skip-chars-forward "[:alnum:]-_.:") |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
816 (point)))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
817 (or (not endp) (eq (char-after cl-end) ?>))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
818 (when clones |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
819 (message "sgml-electric-tag-pair-before-change-function: deleting old OLs") |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
820 (mapc 'delete-overlay clones)) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
821 (message "sgml-electric-tag-pair-before-change-function: new clone") |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
822 (text-clone-create cl-start cl-end 'spread "[[:alnum:]-_.:]+") |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
823 (setq sgml-electric-tag-pair-overlays |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
824 (append (get-char-property (point) 'text-clones) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
825 sgml-electric-tag-pair-overlays)))))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
826 (scan-error nil) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
827 (error (message "Error in sgml-electric-pair-mode: %s" err)))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
828 |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
829 (defun sgml-electric-tag-pair-flush-overlays () |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
830 (while sgml-electric-tag-pair-overlays |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
831 (delete-overlay (pop sgml-electric-tag-pair-overlays)))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
832 |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
833 (define-minor-mode sgml-electric-tag-pair-mode |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
834 "Automatically update the closing tag when editing the opening one." |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
835 :lighter "/e" |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
836 (if sgml-electric-tag-pair-mode |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
837 (progn |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
838 (add-hook 'before-change-functions |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
839 'sgml-electric-tag-pair-before-change-function |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
840 nil t) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
841 (unless sgml-electric-tag-pair-timer |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
842 (setq sgml-electric-tag-pair-timer |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
843 (run-with-idle-timer 5 'repeat 'sgml-electric-tag-pair-flush-overlays)))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
844 (remove-hook 'before-change-functions |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
845 'sgml-electric-tag-pair-before-change-function |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
846 t) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
847 ;; We leave the timer running for other buffers. |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
848 )) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
849 |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
850 |
48109
2c2ce75616ef
(sgml-skip-tag-backward, sgml-skip-tag-forward):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47933
diff
changeset
|
851 (defun sgml-skip-tag-forward (arg) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
852 "Skip to end of tag or matching closing tag if present. |
17551 | 853 With prefix argument ARG, repeat this ARG times. |
78482
80e300a489d6
Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents:
78225
diff
changeset
|
854 Return t if after a closing tag." |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
855 (interactive "p") |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
856 ;; FIXME: Use sgml-get-context or something similar. |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
857 ;; It currently might jump to an unrelated </P> if the <P> |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
858 ;; we're skipping has no matching </P>. |
48109
2c2ce75616ef
(sgml-skip-tag-backward, sgml-skip-tag-forward):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47933
diff
changeset
|
859 (let ((return t)) |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
860 (with-syntax-table sgml-tag-syntax-table |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
861 (while (>= arg 1) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
862 (skip-chars-forward "^<>") |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
863 (if (eq (following-char) ?>) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
864 (up-list -1)) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
865 (if (looking-at "<\\([^/ \n\t>]+\\)\\([^>]*[^/>]\\)?>") |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
866 ;; start tag, skip any nested same pairs _and_ closing tag |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
867 (let ((case-fold-search t) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
868 (re (concat "</?" (regexp-quote (match-string 1)) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
869 ;; Ignore empty tags like <foo/>. |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
870 "\\([^>]*[^/>]\\)?>")) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
871 point close) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
872 (forward-list 1) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
873 (setq point (point)) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
874 ;; FIXME: This re-search-forward will mistakenly match |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
875 ;; tag-like text inside attributes. |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
876 (while (and (re-search-forward re nil t) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
877 (not (setq close |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
878 (eq (char-after (1+ (match-beginning 0))) ?/))) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
879 (goto-char (match-beginning 0)) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
880 (sgml-skip-tag-forward 1)) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
881 (setq close nil)) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
882 (unless close |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
883 (goto-char point) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
884 (setq return nil))) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
885 (forward-list 1)) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
886 (setq arg (1- arg))) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
887 return))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
888 |
105737
2009126d46e1
(sgml-looking-back-at): Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
105664
diff
changeset
|
889 (defsubst sgml-looking-back-at (str) |
2009126d46e1
(sgml-looking-back-at): Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
105664
diff
changeset
|
890 "Return t if the test before point matches STR." |
2009126d46e1
(sgml-looking-back-at): Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
105664
diff
changeset
|
891 (let ((start (- (point) (length str)))) |
2009126d46e1
(sgml-looking-back-at): Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
105664
diff
changeset
|
892 (and (>= start (point-min)) |
2009126d46e1
(sgml-looking-back-at): Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
105664
diff
changeset
|
893 (equal str (buffer-substring-no-properties start (point)))))) |
2009126d46e1
(sgml-looking-back-at): Move definition before use.
Glenn Morris <rgm@gnu.org>
parents:
105664
diff
changeset
|
894 |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
895 (defun sgml-delete-tag (arg) |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
896 ;; FIXME: Should be called sgml-kill-tag or should not touch the kill-ring. |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
897 "Delete tag on or after cursor, and matching closing or opening tag. |
17551 | 898 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
|
899 (interactive "p") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
900 (while (>= arg 1) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
901 (save-excursion |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
902 (let* (close open) |
14270
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
903 (if (looking-at "[ \t\n]*<") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
904 ;; just before tag |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
905 (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
|
906 ;; closing tag |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
907 (progn |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
908 (setq close (point)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
909 (goto-char (match-end 0)))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
910 ;; on tag? |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
911 (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
|
912 close (and (stringp close) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
913 (eq (aref close 0) ?/) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
914 (point)))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
915 ;; not on closing tag |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
916 (let ((point (point))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
917 (sgml-skip-tag-backward 1) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
918 (if (or (not (eq (following-char) ?<)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
919 (save-excursion |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
920 (forward-list 1) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
921 (<= (point) point))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
922 (error "Not on or before tag"))))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
923 (if close |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
924 (progn |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
925 (sgml-skip-tag-backward 1) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
926 (setq open (point)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
927 (goto-char close) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
928 (kill-sexp 1)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
929 (setq open (point)) |
60521 | 930 (when (and (sgml-skip-tag-forward 1) |
105664
6a6fcf3e8e4d
* minibuffer.el (read-file-name): Check for repeat before putting
Chong Yidong <cyd@stupidchicken.com>
parents:
105662
diff
changeset
|
931 (not (sgml-looking-back-at "/>"))) |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
932 (kill-sexp -1))) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
933 ;; Delete any resulting empty line. If we didn't kill-sexp, |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
934 ;; this *should* do nothing, because we're right after the tag. |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
935 (if (progn (forward-line 0) (looking-at "\\(?:[ \t]*$\\)\n?")) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
936 (delete-region (match-beginning 0) (match-end 0))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
937 (goto-char open) |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
938 (kill-sexp 1) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
939 (if (progn (forward-line 0) (looking-at "\\(?:[ \t]*$\\)\n?")) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
940 (delete-region (match-beginning 0) (match-end 0))))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
941 (setq arg (1- arg)))) |
44459
25c3c51b0375
(sgml-tag-alist): Doc fix.
Mike Williams <mdub@bigfoot.com>
parents:
44443
diff
changeset
|
942 |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
943 |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
944 ;; 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
|
945 (or (get 'sgml-tag 'invisible) |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
946 (setplist 'sgml-tag |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
947 (append '(invisible t |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
948 point-entered sgml-point-entered |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
949 rear-nonsticky t |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
950 read-only t) |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
951 (symbol-plist 'sgml-tag)))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
952 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
953 (defun sgml-tags-invisible (arg) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
954 "Toggle visibility of existing tags." |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
955 (interactive "P") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
956 (let ((modified (buffer-modified-p)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
957 (inhibit-read-only t) |
38068
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
958 (inhibit-modification-hooks t) |
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
959 ;; Avoid spurious the `file-locked' checks. |
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
960 (buffer-file-name nil) |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
961 ;; 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
|
962 ;; 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
|
963 ;; 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
|
964 (inhibit-point-motion-hooks t) |
40320
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
965 string) |
38068
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
966 (unwind-protect |
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
967 (save-excursion |
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
968 (goto-char (point-min)) |
40392
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
969 (if (set (make-local-variable 'sgml-tags-invisible) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
970 (if arg |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
971 (>= (prefix-numeric-value arg) 0) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
972 (not sgml-tags-invisible))) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
973 (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
|
974 (setq string |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
975 (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
|
976 sgml-display-text))) |
38068
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
977 (goto-char (match-beginning 0)) |
40320
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
978 (and (stringp string) |
38068
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
979 (not (overlays-at (point))) |
40392
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
980 (let ((ol (make-overlay (point) (match-beginning 1)))) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
981 (overlay-put ol 'before-string string) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
982 (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
|
983 (put-text-property (point) |
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
984 (progn (forward-list) (point)) |
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
985 'category 'sgml-tag)) |
40320
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
986 (let ((pos (point-min))) |
38068
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
987 (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
|
988 (dolist (ol (overlays-at pos)) |
40393
591afd36f0b3
(sgml-tags-invisible): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40392
diff
changeset
|
989 (if (overlay-get ol 'sgml-tag) |
40392
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
990 (delete-overlay ol))))) |
40320
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
991 (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
|
992 (restore-buffer-modified-p modified)) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
993 (run-hooks 'sgml-tags-invisible-hook) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
994 (message ""))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
995 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
996 (defun sgml-point-entered (x y) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
997 ;; 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
|
998 (let ((inhibit-point-motion-hooks t)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
999 (save-excursion |
77825
72e7efdd6433
(sgml-point-entered): Use condition-case.
Chong Yidong <cyd@stupidchicken.com>
parents:
76104
diff
changeset
|
1000 (condition-case nil |
72e7efdd6433
(sgml-point-entered): Use condition-case.
Chong Yidong <cyd@stupidchicken.com>
parents:
76104
diff
changeset
|
1001 (message "Invisible tag: %s" |
72e7efdd6433
(sgml-point-entered): Use condition-case.
Chong Yidong <cyd@stupidchicken.com>
parents:
76104
diff
changeset
|
1002 ;; Strip properties, otherwise, the text is invisible. |
72e7efdd6433
(sgml-point-entered): Use condition-case.
Chong Yidong <cyd@stupidchicken.com>
parents:
76104
diff
changeset
|
1003 (buffer-substring-no-properties |
72e7efdd6433
(sgml-point-entered): Use condition-case.
Chong Yidong <cyd@stupidchicken.com>
parents:
76104
diff
changeset
|
1004 (point) |
72e7efdd6433
(sgml-point-entered): Use condition-case.
Chong Yidong <cyd@stupidchicken.com>
parents:
76104
diff
changeset
|
1005 (if (or (and (> x y) |
72e7efdd6433
(sgml-point-entered): Use condition-case.
Chong Yidong <cyd@stupidchicken.com>
parents:
76104
diff
changeset
|
1006 (not (eq (following-char) ?<))) |
72e7efdd6433
(sgml-point-entered): Use condition-case.
Chong Yidong <cyd@stupidchicken.com>
parents:
76104
diff
changeset
|
1007 (and (< x y) |
72e7efdd6433
(sgml-point-entered): Use condition-case.
Chong Yidong <cyd@stupidchicken.com>
parents:
76104
diff
changeset
|
1008 (eq (preceding-char) ?>))) |
72e7efdd6433
(sgml-point-entered): Use condition-case.
Chong Yidong <cyd@stupidchicken.com>
parents:
76104
diff
changeset
|
1009 (backward-list) |
72e7efdd6433
(sgml-point-entered): Use condition-case.
Chong Yidong <cyd@stupidchicken.com>
parents:
76104
diff
changeset
|
1010 (forward-list)))) |
72e7efdd6433
(sgml-point-entered): Use condition-case.
Chong Yidong <cyd@stupidchicken.com>
parents:
76104
diff
changeset
|
1011 (error nil))))) |
72e7efdd6433
(sgml-point-entered): Use condition-case.
Chong Yidong <cyd@stupidchicken.com>
parents:
76104
diff
changeset
|
1012 |
44459
25c3c51b0375
(sgml-tag-alist): Doc fix.
Mike Williams <mdub@bigfoot.com>
parents:
44443
diff
changeset
|
1013 |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
1014 |
809 | 1015 (defun sgml-validate (command) |
1016 "Validate an SGML document. | |
1017 Runs COMMAND, a shell command, in a separate process asynchronously | |
17551 | 1018 with output going to the buffer `*compilation*'. |
809 | 1019 You can then use the command \\[next-error] to find the next error message |
1020 and move to the line in the SGML document that caused it." | |
1021 (interactive | |
1022 (list (read-string "Validate command: " | |
1023 (or sgml-saved-validate-command | |
1024 (concat sgml-validate-command | |
1025 " " | |
76104
33363c78b671
(sgml-validate): Quote the file name with shell-quote-argument.
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
1026 (shell-quote-argument |
33363c78b671
(sgml-validate): Quote the file name with shell-quote-argument.
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
1027 (let ((name (buffer-file-name))) |
33363c78b671
(sgml-validate): Quote the file name with shell-quote-argument.
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
1028 (and name |
33363c78b671
(sgml-validate): Quote the file name with shell-quote-argument.
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
1029 (file-name-nondirectory name))))))))) |
809 | 1030 (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
|
1031 (save-some-buffers (not compilation-ask-about-save) nil) |
65133
265f46863d5b
(sgml-validate): Use `compilation-start'
Romain Francoise <romain@orebokech.com>
parents:
64993
diff
changeset
|
1032 (compilation-start command)) |
809 | 1033 |
44619
504c3192243a
(sgml-at-indentation-p): Move to fix compilation error.
Mike Williams <mdub@bigfoot.com>
parents:
44582
diff
changeset
|
1034 (defsubst sgml-at-indentation-p () |
504c3192243a
(sgml-at-indentation-p): Move to fix compilation error.
Mike Williams <mdub@bigfoot.com>
parents:
44582
diff
changeset
|
1035 "Return true if point is at the first non-whitespace character on the line." |
504c3192243a
(sgml-at-indentation-p): Move to fix compilation error.
Mike Williams <mdub@bigfoot.com>
parents:
44582
diff
changeset
|
1036 (save-excursion |
504c3192243a
(sgml-at-indentation-p): Move to fix compilation error.
Mike Williams <mdub@bigfoot.com>
parents:
44582
diff
changeset
|
1037 (skip-chars-backward " \t") |
504c3192243a
(sgml-at-indentation-p): Move to fix compilation error.
Mike Williams <mdub@bigfoot.com>
parents:
44582
diff
changeset
|
1038 (bolp))) |
504c3192243a
(sgml-at-indentation-p): Move to fix compilation error.
Mike Williams <mdub@bigfoot.com>
parents:
44582
diff
changeset
|
1039 |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1040 (defun sgml-lexical-context (&optional limit) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1041 "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
|
1042 START is the location of the start of the lexical element. |
80876
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1043 TYPE is one of `string', `comment', `tag', `cdata', `pi', or `text'. |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1044 |
44460
45c30120001e
(sgml-lexical-context): Use sgml-parse-tag-backward to find start point.
Mike Williams <mdub@bigfoot.com>
parents:
44459
diff
changeset
|
1045 Optional argument LIMIT is the position to start parsing from. |
45c30120001e
(sgml-lexical-context): Use sgml-parse-tag-backward to find start point.
Mike Williams <mdub@bigfoot.com>
parents:
44459
diff
changeset
|
1046 If nil, start from a preceding tag at indentation." |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1047 (save-excursion |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1048 (let ((pos (point)) |
44387
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1049 text-start state) |
44460
45c30120001e
(sgml-lexical-context): Use sgml-parse-tag-backward to find start point.
Mike Williams <mdub@bigfoot.com>
parents:
44459
diff
changeset
|
1050 (if limit |
45c30120001e
(sgml-lexical-context): Use sgml-parse-tag-backward to find start point.
Mike Williams <mdub@bigfoot.com>
parents:
44459
diff
changeset
|
1051 (goto-char limit) |
45c30120001e
(sgml-lexical-context): Use sgml-parse-tag-backward to find start point.
Mike Williams <mdub@bigfoot.com>
parents:
44459
diff
changeset
|
1052 ;; Skip tags backwards until we find one at indentation |
45c30120001e
(sgml-lexical-context): Use sgml-parse-tag-backward to find start point.
Mike Williams <mdub@bigfoot.com>
parents:
44459
diff
changeset
|
1053 (while (and (ignore-errors (sgml-parse-tag-backward)) |
45c30120001e
(sgml-lexical-context): Use sgml-parse-tag-backward to find start point.
Mike Williams <mdub@bigfoot.com>
parents:
44459
diff
changeset
|
1054 (not (sgml-at-indentation-p))))) |
44241
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1055 (with-syntax-table sgml-tag-syntax-table |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1056 (while (< (point) pos) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1057 ;; When entering this loop we're inside text. |
44335
1a7be1d554f5
(sgml-looking-back-at): Short-circuit at beg of buffer.
Mike Williams <mdub@bigfoot.com>
parents:
44333
diff
changeset
|
1058 (setq text-start (point)) |
44241
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1059 (skip-chars-forward "^<" pos) |
44387
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1060 (setq state |
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1061 (cond |
44443
9e6f2afa9f19
(sgml-comment-indent-new-line): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44388
diff
changeset
|
1062 ((= (point) pos) |
44387
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1063 ;; We got to the end without seeing a tag. |
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1064 nil) |
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1065 ((looking-at "<!\\[[A-Z]+\\[") |
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1066 ;; We've found a CDATA section or similar. |
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1067 (let ((cdata-start (point))) |
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1068 (unless (search-forward "]]>" pos 'move) |
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1069 (list 0 nil nil 'cdata nil nil nil nil cdata-start)))) |
106435
9e1a89d804c8
* textmodes/sgml-mode.el (sgml-lexical-context): Recognise
Chong Yidong <cyd@stupidchicken.com>
parents:
105821
diff
changeset
|
1070 ((looking-at comment-start-skip) |
9e1a89d804c8
* textmodes/sgml-mode.el (sgml-lexical-context): Recognise
Chong Yidong <cyd@stupidchicken.com>
parents:
105821
diff
changeset
|
1071 ;; parse-partial-sexp doesn't handle <!-- comments -->, |
9e1a89d804c8
* textmodes/sgml-mode.el (sgml-lexical-context): Recognise
Chong Yidong <cyd@stupidchicken.com>
parents:
105821
diff
changeset
|
1072 ;; or only if ?- is in sgml-specials, so match explicitly |
9e1a89d804c8
* textmodes/sgml-mode.el (sgml-lexical-context): Recognise
Chong Yidong <cyd@stupidchicken.com>
parents:
105821
diff
changeset
|
1073 (let ((start (point))) |
9e1a89d804c8
* textmodes/sgml-mode.el (sgml-lexical-context): Recognise
Chong Yidong <cyd@stupidchicken.com>
parents:
105821
diff
changeset
|
1074 (unless (re-search-forward comment-end-skip pos 'move) |
9e1a89d804c8
* textmodes/sgml-mode.el (sgml-lexical-context): Recognise
Chong Yidong <cyd@stupidchicken.com>
parents:
105821
diff
changeset
|
1075 (list 0 nil nil nil t nil nil nil start)))) |
80876
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1076 ((and sgml-xml-mode (looking-at "<\\?")) |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1077 ;; Processing Instructions. |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1078 ;; In SGML, it's basically a normal tag of the form |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1079 ;; <?NAME ...> but in XML, it takes the form <? ... ?>. |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1080 (let ((pi-start (point))) |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1081 (unless (search-forward "?>" pos 'move) |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1082 (list 0 nil nil 'pi nil nil nil nil pi-start)))) |
44387
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1083 (t |
44502
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1084 ;; We've reached a tag. Parse it. |
44387
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1085 ;; FIXME: Handle net-enabling start-tags |
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1086 (parse-partial-sexp (point) pos 0)))))) |
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1087 (cond |
80876
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1088 ((memq (nth 3 state) '(cdata pi)) (cons (nth 3 state) (nth 8 state))) |
44387
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1089 ((nth 3 state) (cons 'string (nth 8 state))) |
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1090 ((nth 4 state) (cons 'comment (nth 8 state))) |
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1091 ((and state (> (nth 0 state) 0)) (cons 'tag (nth 1 state))) |
a8edf3f6811d
(sgml-lexical-context): Fix up CDATA detection for boundary cases.
Mike Williams <mdub@bigfoot.com>
parents:
44362
diff
changeset
|
1092 (t (cons 'text text-start)))))) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1093 |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1094 (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
|
1095 "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
|
1096 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
|
1097 (let ((context (sgml-lexical-context))) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1098 (if (eq (car context) 'tag) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1099 (progn |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1100 (goto-char (cdr context)) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1101 (when (looking-at sgml-tag-name-re) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1102 (match-string-no-properties 1))) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1103 (if top-level nil |
44244
31f1fc31fd45
(sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44241
diff
changeset
|
1104 (when (not (eq (car context) 'text)) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1105 (goto-char (cdr context)) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1106 (sgml-beginning-of-tag t)))))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1107 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1108 (defun sgml-value (alist) |
44286
1d7ee8515c45
Add an explicit check for 'text syntax, to protect against future
Mike Williams <mdub@bigfoot.com>
parents:
44244
diff
changeset
|
1109 "Interactively insert value taken from attribute-rule ALIST. |
40343
25129ef47b45
some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents:
40320
diff
changeset
|
1110 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
|
1111 (setq alist (cdr alist)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1112 (if (stringp (car alist)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1113 (insert "=\"" (car alist) ?\") |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
1114 (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
|
1115 (when (cdr alist) |
40392
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
1116 (insert "=\"") |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
1117 (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
|
1118 (if (string< "" alist) |
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
1119 (insert alist ?\") |
108765
d835100c3e8b
Replace Lisp calls to delete-backward-char by delete-char.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
108541
diff
changeset
|
1120 (delete-char -2))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1121 (insert "=\"") |
80889
8938fa90afdb
(sgml-value): Fix handling of attributes which can take any number of values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80876
diff
changeset
|
1122 (if (cdr alist) |
8938fa90afdb
(sgml-value): Fix handling of attributes which can take any number of values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80876
diff
changeset
|
1123 (insert (skeleton-read '(completing-read "Value: " alist))) |
8938fa90afdb
(sgml-value): Fix handling of attributes which can take any number of values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80876
diff
changeset
|
1124 (when (null alist) |
8938fa90afdb
(sgml-value): Fix handling of attributes which can take any number of values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
80876
diff
changeset
|
1125 (insert (skeleton-read '(read-string "Value: "))))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1126 (insert ?\")))) |
40320
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1127 |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1128 (defun sgml-quote (start end &optional unquotep) |
46352
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1129 "Quote SGML text in region START ... END. |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1130 Only &, < and > are quoted, the rest is left untouched. |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1131 With prefix argument UNQUOTEP, unquote the region." |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1132 (interactive "r\nP") |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1133 (save-restriction |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1134 (narrow-to-region start end) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1135 (goto-char (point-min)) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1136 (if unquotep |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1137 ;; FIXME: We should unquote other named character references as well. |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1138 (while (re-search-forward |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1139 "\\(&\\(amp\\|\\(l\\|\\(g\\)\\)t\\)\\)[][<>&;\n\t \"%!'(),/=?]" |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1140 nil t) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1141 (replace-match (if (match-end 4) ">" (if (match-end 3) "<" "&")) t t |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1142 nil (if (eq (char-before (match-end 0)) ?\;) 0 1))) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1143 (while (re-search-forward "[&<>]" nil t) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1144 (replace-match (cdr (assq (char-before) '((?& . "&") |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1145 (?< . "<") |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1146 (?> . ">")))) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1147 t t))))) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1148 |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1149 (defun sgml-pretty-print (beg end) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1150 "Simple-minded pretty printer for SGML. |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1151 Re-indents the code and inserts newlines between BEG and END. |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1152 You might want to turn on `auto-fill-mode' to get better results." |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1153 ;; TODO: |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1154 ;; - insert newline between some start-tag and text. |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1155 ;; - don't insert newline in front of some end-tags. |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1156 (interactive "r") |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1157 (save-excursion |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1158 (if (< beg end) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1159 (goto-char beg) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1160 (goto-char end) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1161 (setq end beg) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1162 (setq beg (point))) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1163 ;; Don't use narrowing because it screws up auto-indent. |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1164 (setq end (copy-marker end t)) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1165 (with-syntax-table sgml-tag-syntax-table |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1166 (while (re-search-forward "<" end t) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1167 (goto-char (match-beginning 0)) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1168 (unless (or ;;(looking-at "</") |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1169 (progn (skip-chars-backward " \t") (bolp))) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1170 (reindent-then-newline-and-indent)) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1171 (forward-sexp 1))) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1172 ;; (indent-region beg end) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1173 )) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1174 |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1175 |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1176 ;; Parsing |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1177 |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1178 (defstruct (sgml-tag |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1179 (:constructor sgml-make-tag (type start end name))) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1180 type start end name) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1181 |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1182 (defsubst sgml-parse-tag-name () |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1183 "Skip past a tag-name, and return the name." |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1184 (buffer-substring-no-properties |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1185 (point) (progn (skip-syntax-forward "w_") (point)))) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1186 |
58122
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1187 (defun sgml-tag-text-p (start end) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1188 "Return non-nil if text between START and END is a tag. |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1189 Checks among other things that the tag does not contain spurious |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1190 unquoted < or > chars inside, which would indicate that it |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1191 really isn't a tag after all." |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1192 (save-excursion |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1193 (with-syntax-table sgml-tag-syntax-table |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1194 (let ((pps (parse-partial-sexp start end 2))) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1195 (and (= (nth 0 pps) 0)))))) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1196 |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
1197 (defun sgml-parse-tag-backward (&optional limit) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1198 "Parse an SGML tag backward, and return information about the tag. |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1199 Assume that parsing starts from within a textual context. |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1200 Leave point at the beginning of the tag." |
58122
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1201 (catch 'found |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1202 (let (tag-type tag-start tag-end name) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1203 (or (re-search-backward "[<>]" limit 'move) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1204 (error "No tag found")) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1205 (when (eq (char-after) ?<) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1206 ;; Oops!! Looks like we were not in a textual context after all!. |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1207 ;; Let's try to recover. |
80876
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1208 ;; Remember the tag-start so we don't need to look for it later. |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1209 ;; This is not just an optimization but also makes sure we don't get |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1210 ;; stuck in infloops in cases where "looking back for <" would not go |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1211 ;; back far enough. |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1212 (setq tag-start (point)) |
58122
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1213 (with-syntax-table sgml-tag-syntax-table |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1214 (let ((pos (point))) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1215 (condition-case nil |
80876
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1216 ;; FIXME: This does not correctly skip over PI an CDATA tags. |
58122
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1217 (forward-sexp) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1218 (scan-error |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1219 ;; This < seems to be just a spurious one, let's ignore it. |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1220 (goto-char pos) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1221 (throw 'found (sgml-parse-tag-backward limit)))) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1222 ;; Check it is really a tag, without any extra < or > inside. |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1223 (unless (sgml-tag-text-p pos (point)) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1224 (goto-char pos) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1225 (throw 'found (sgml-parse-tag-backward limit))) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1226 (forward-char -1)))) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1227 (setq tag-end (1+ (point))) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1228 (cond |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1229 ((sgml-looking-back-at "--") ; comment |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1230 (setq tag-type 'comment |
80876
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1231 tag-start (or tag-start (search-backward "<!--" nil t)))) |
58122
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1232 ((sgml-looking-back-at "]]") ; cdata |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1233 (setq tag-type 'cdata |
80876
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1234 tag-start (or tag-start |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1235 (re-search-backward "<!\\[[A-Z]+\\[" nil t)))) |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1236 ((sgml-looking-back-at "?") ; XML processing-instruction |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1237 (setq tag-type 'pi |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1238 ;; IIUC: SGML processing instructions take the form <?foo ...> |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1239 ;; i.e. a "normal" tag, handled below. In XML this is changed |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1240 ;; to <?foo ... ?> where "..." can contain < and > and even <? |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1241 ;; but not ?>. This means that when parsing backward, there's |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1242 ;; no easy way to make sure that we find the real beginning of |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1243 ;; the PI. |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1244 tag-start (or tag-start (search-backward "<?" nil t)))) |
58122
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1245 (t |
80876
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1246 (unless tag-start |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1247 (setq tag-start |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1248 (with-syntax-table sgml-tag-syntax-table |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1249 (goto-char tag-end) |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1250 (condition-case nil |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1251 (backward-sexp) |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1252 (scan-error |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1253 ;; This > isn't really the end of a tag. Skip it. |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1254 (goto-char (1- tag-end)) |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1255 (throw 'found (sgml-parse-tag-backward limit)))) |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1256 (point)))) |
58122
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1257 (goto-char (1+ tag-start)) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1258 (case (char-after) |
80876
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1259 (?! (setq tag-type 'decl)) ; declaration |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1260 (?? (setq tag-type 'pi)) ; processing-instruction |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1261 (?% (setq tag-type 'jsp)) ; JSP tags |
58122
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1262 (?/ ; close-tag |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1263 (forward-char 1) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1264 (setq tag-type 'close |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1265 name (sgml-parse-tag-name))) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1266 (t ; open or empty tag |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1267 (setq tag-type 'open |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1268 name (sgml-parse-tag-name)) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1269 (if (or (eq ?/ (char-before (- tag-end 1))) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1270 (sgml-empty-tag-p name)) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1271 (setq tag-type 'empty)))))) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1272 (goto-char tag-start) |
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
1273 (sgml-make-tag tag-type tag-start tag-end name)))) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1274 |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1275 (defun sgml-get-context (&optional until) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1276 "Determine the context of the current position. |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1277 By default, parse until we find a start-tag as the first thing on a line. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1278 If UNTIL is `empty', return even if the context is empty (i.e. |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1279 we just skipped over some element and got to a beginning of line). |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1280 |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1281 The context is a list of tag-info structures. The last one is the tag |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1282 immediately enclosing the current position. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1283 |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1284 Point is assumed to be outside of any tag. If we discover that it's |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1285 not the case, the first tag returned is the one inside which we are." |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1286 (let ((here (point)) |
59519
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1287 (stack nil) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1288 (ignore nil) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1289 (context nil) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1290 tag-info) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1291 ;; CONTEXT keeps track of the tag-stack |
59519
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1292 ;; STACK keeps track of the end tags we've seen (and thus the start-tags |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1293 ;; we'll have to ignore) when skipping over matching open..close pairs. |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1294 ;; IGNORE is a list of tags that can be ignored because they have been |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1295 ;; closed implicitly. |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1296 (skip-chars-backward " \t\n") ; Make sure we're not at indentation. |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1297 (while |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1298 (and (not (eq until 'now)) |
59519
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1299 (or stack |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1300 (not (if until (eq until 'empty) context)) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1301 (not (sgml-at-indentation-p)) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1302 (and context |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1303 (/= (point) (sgml-tag-start (car context))) |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1304 (sgml-unclosed-tag-p (sgml-tag-name (car context))))) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1305 (setq tag-info (ignore-errors (sgml-parse-tag-backward)))) |
47933
b5ddbda34d8e
(sgml-close-tag, html-imenu-index): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47679
diff
changeset
|
1306 |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1307 ;; This tag may enclose things we thought were tags. If so, |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1308 ;; discard them. |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1309 (while (and context |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1310 (> (sgml-tag-end tag-info) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1311 (sgml-tag-end (car context)))) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1312 (setq context (cdr context))) |
47933
b5ddbda34d8e
(sgml-close-tag, html-imenu-index): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47679
diff
changeset
|
1313 |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1314 (cond |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1315 ((> (sgml-tag-end tag-info) here) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1316 ;; Oops!! Looks like we were not outside of any tag, after all. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1317 (push tag-info context) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1318 (setq until 'now)) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1319 |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1320 ;; start-tag |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1321 ((eq (sgml-tag-type tag-info) 'open) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1322 (cond |
59519
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1323 ((null stack) |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
1324 (if (assoc-string (sgml-tag-name tag-info) ignore t) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1325 ;; There was an implicit end-tag. |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1326 nil |
59519
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1327 (push tag-info context) |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1328 ;; We're changing context so the tags implicitly closed inside |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1329 ;; the previous context aren't implicitly closed here any more. |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1330 ;; [ Well, actually it depends, but we don't have the info about |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1331 ;; when it doesn't and when it does. --Stef ] |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1332 (setq ignore nil))) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1333 ((eq t (compare-strings (sgml-tag-name tag-info) nil nil |
59519
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1334 (car stack) nil nil t)) |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1335 (setq stack (cdr stack))) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1336 (t |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1337 ;; The open and close tags don't match. |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1338 (if (not sgml-xml-mode) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1339 (unless (sgml-unclosed-tag-p (sgml-tag-name tag-info)) |
46352
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1340 (message "Unclosed tag <%s>" (sgml-tag-name tag-info)) |
59519
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1341 (let ((tmp stack)) |
46352
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1342 ;; We could just assume that the tag is simply not closed |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1343 ;; but it's a bad assumption when tags *are* closed but |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1344 ;; not properly nested. |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1345 (while (and (cdr tmp) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1346 (not (eq t (compare-strings |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1347 (sgml-tag-name tag-info) nil nil |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1348 (cadr tmp) nil nil t)))) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1349 (setq tmp (cdr tmp))) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1350 (if (cdr tmp) (setcdr tmp (cddr tmp))))) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1351 (message "Unmatched tags <%s> and </%s>" |
59519
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1352 (sgml-tag-name tag-info) (pop stack))))) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59519
diff
changeset
|
1353 |
59519
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1354 (if (and (null stack) (sgml-unclosed-tag-p (sgml-tag-name tag-info))) |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1355 ;; This is a top-level open of an implicitly closed tag, so any |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1356 ;; occurrence of such an open tag at the same level can be ignored |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1357 ;; because it's been implicitly closed. |
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1358 (push (sgml-tag-name tag-info) ignore))) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1359 |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1360 ;; end-tag |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1361 ((eq (sgml-tag-type tag-info) 'close) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1362 (if (sgml-empty-tag-p (sgml-tag-name tag-info)) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1363 (message "Spurious </%s>: empty tag" (sgml-tag-name tag-info)) |
59519
e51199adcfb0
(sgml-fill-nobreak): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58122
diff
changeset
|
1364 (push (sgml-tag-name tag-info) stack))) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1365 )) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1366 |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1367 ;; return context |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1368 context)) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1369 |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1370 (defun sgml-show-context (&optional full) |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1371 "Display the current context. |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1372 If FULL is non-nil, parse back to the beginning of the buffer." |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1373 (interactive "P") |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1374 (with-output-to-temp-buffer "*XML Context*" |
46352
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1375 (save-excursion |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1376 (let ((context (sgml-get-context))) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1377 (when full |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1378 (let ((more nil)) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1379 (while (setq more (sgml-get-context)) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1380 (setq context (nconc more context))))) |
66fb3c24b4ba
(sgml-quote): Use narrowing. Improve the regexp used when unquoting.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45557
diff
changeset
|
1381 (pp context))))) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1382 |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1383 |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1384 ;; Editing shortcuts |
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1385 |
44333
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1386 (defun sgml-close-tag () |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
1387 "Close current element. |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
1388 Depending on context, inserts a matching close-tag, or closes |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
1389 the current start-tag or the current comment or the current cdata, ..." |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1390 (interactive) |
44333
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1391 (case (car (sgml-lexical-context)) |
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1392 (comment (insert " -->")) |
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1393 (cdata (insert "]]>")) |
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1394 (pi (insert " ?>")) |
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1395 (jsp (insert " %>")) |
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1396 (tag (insert " />")) |
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1397 (text |
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1398 (let ((context (save-excursion (sgml-get-context)))) |
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1399 (if context |
44502
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1400 (progn |
44333
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1401 (insert "</" (sgml-tag-name (car (last context))) ">") |
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1402 (indent-according-to-mode))))) |
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1403 (otherwise |
efbd9e76f0a4
(sgml-close-tag): Rename from
Mike Williams <mdub@bigfoot.com>
parents:
44330
diff
changeset
|
1404 (error "Nothing to close")))) |
44330
96c839b7b4c2
(sgml-at-indentation-p, sgml-tag)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44293
diff
changeset
|
1405 |
44286
1d7ee8515c45
Add an explicit check for 'text syntax, to protect against future
Mike Williams <mdub@bigfoot.com>
parents:
44244
diff
changeset
|
1406 (defun sgml-empty-tag-p (tag-name) |
1d7ee8515c45
Add an explicit check for 'text syntax, to protect against future
Mike Williams <mdub@bigfoot.com>
parents:
44244
diff
changeset
|
1407 "Return non-nil if TAG-NAME is an implicitly empty tag." |
1d7ee8515c45
Add an explicit check for 'text syntax, to protect against future
Mike Williams <mdub@bigfoot.com>
parents:
44244
diff
changeset
|
1408 (and (not sgml-xml-mode) |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
1409 (assoc-string tag-name sgml-empty-tags 'ignore-case))) |
44286
1d7ee8515c45
Add an explicit check for 'text syntax, to protect against future
Mike Williams <mdub@bigfoot.com>
parents:
44244
diff
changeset
|
1410 |
1d7ee8515c45
Add an explicit check for 'text syntax, to protect against future
Mike Williams <mdub@bigfoot.com>
parents:
44244
diff
changeset
|
1411 (defun sgml-unclosed-tag-p (tag-name) |
1d7ee8515c45
Add an explicit check for 'text syntax, to protect against future
Mike Williams <mdub@bigfoot.com>
parents:
44244
diff
changeset
|
1412 "Return non-nil if TAG-NAME is a tag for which an end-tag is optional." |
1d7ee8515c45
Add an explicit check for 'text syntax, to protect against future
Mike Williams <mdub@bigfoot.com>
parents:
44244
diff
changeset
|
1413 (and (not sgml-xml-mode) |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
1414 (assoc-string tag-name sgml-unclosed-tags 'ignore-case))) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
1415 |
44286
1d7ee8515c45
Add an explicit check for 'text syntax, to protect against future
Mike Williams <mdub@bigfoot.com>
parents:
44244
diff
changeset
|
1416 |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1417 (defun sgml-calculate-indent (&optional lcon) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1418 "Calculate the column to which this line should be indented. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1419 LCON is the lexical context, if any." |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1420 (unless lcon (setq lcon (sgml-lexical-context))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1421 |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1422 ;; Indent comment-start markers inside <!-- just like comment-end markers. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1423 (if (and (eq (car lcon) 'tag) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1424 (looking-at "--") |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1425 (save-excursion (goto-char (cdr lcon)) (looking-at "<!--"))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1426 (setq lcon (cons 'comment (+ (cdr lcon) 2)))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1427 |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1428 (case (car lcon) |
44286
1d7ee8515c45
Add an explicit check for 'text syntax, to protect against future
Mike Williams <mdub@bigfoot.com>
parents:
44244
diff
changeset
|
1429 |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1430 (string |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1431 ;; Go back to previous non-empty line. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1432 (while (and (> (point) (cdr lcon)) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1433 (zerop (forward-line -1)) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1434 (looking-at "[ \t]*$"))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1435 (if (> (point) (cdr lcon)) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1436 ;; Previous line is inside the string. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1437 (current-indentation) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1438 (goto-char (cdr lcon)) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1439 (1+ (current-column)))) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1440 |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1441 (comment |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1442 (let ((mark (looking-at "--"))) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1443 ;; Go back to previous non-empty line. |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1444 (while (and (> (point) (cdr lcon)) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1445 (zerop (forward-line -1)) |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1446 (or (looking-at "[ \t]*$") |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1447 (if mark (not (looking-at "[ \t]*--")))))) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1448 (if (> (point) (cdr lcon)) |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1449 ;; Previous line is inside the comment. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1450 (skip-chars-forward " \t") |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1451 (goto-char (cdr lcon)) |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1452 ;; Skip `<!' to get to the `--' with which we want to align. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1453 (search-forward "--") |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1454 (goto-char (match-beginning 0))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1455 (when (and (not mark) (looking-at "--")) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1456 (forward-char 2) (skip-chars-forward " \t")) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1457 (current-column))) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1458 |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1459 ;; We don't know how to indent it. Let's be honest about it. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1460 (cdata nil) |
80876
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1461 ;; We don't know how to indent it. Let's be honest about it. |
f46158b1c8bc
(sgml-lexical-context): Add handling of XML style Processing Instructions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76104
diff
changeset
|
1462 (pi nil) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1463 |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1464 (tag |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1465 (goto-char (1+ (cdr lcon))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1466 (skip-chars-forward "^ \t\n") ;Skip tag name. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1467 (skip-chars-forward " \t") |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1468 (if (not (eolp)) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1469 (current-column) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1470 ;; This is the first attribute: indent. |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1471 (goto-char (1+ (cdr lcon))) |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1472 (+ (current-column) sgml-basic-offset))) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1473 |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1474 (text |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1475 (while (looking-at "</") |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1476 (forward-sexp 1) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1477 (skip-chars-forward " \t")) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1478 (let* ((here (point)) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1479 (unclosed (and ;; (not sgml-xml-mode) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1480 (looking-at sgml-tag-name-re) |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
1481 (assoc-string (match-string 1) |
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
1482 sgml-unclosed-tags 'ignore-case) |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1483 (match-string 1))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1484 (context |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1485 ;; If possible, align on the previous non-empty text line. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1486 ;; Otherwise, do a more serious parsing to find the |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1487 ;; tag(s) relative to which we should be indenting. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1488 (if (and (not unclosed) (skip-chars-backward " \t") |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1489 (< (skip-chars-backward " \t\n") 0) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1490 (back-to-indentation) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1491 (> (point) (cdr lcon))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1492 nil |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1493 (goto-char here) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1494 (nreverse (sgml-get-context (if unclosed nil 'empty))))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1495 (there (point))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1496 ;; Ignore previous unclosed start-tag in context. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1497 (while (and context unclosed |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1498 (eq t (compare-strings |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1499 (sgml-tag-name (car context)) nil nil |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1500 unclosed nil nil t))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1501 (setq context (cdr context))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1502 ;; Indent to reflect nesting. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1503 (cond |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1504 ;; If we were not in a text context after all, let's try again. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1505 ((and context (> (sgml-tag-end (car context)) here)) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1506 (goto-char here) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1507 (sgml-calculate-indent |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1508 (cons (if (memq (sgml-tag-type (car context)) '(comment cdata)) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1509 (sgml-tag-type (car context)) 'tag) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1510 (sgml-tag-start (car context))))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1511 ;; Align on the first element after the nearest open-tag, if any. |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1512 ((and context |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1513 (goto-char (sgml-tag-end (car context))) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1514 (skip-chars-forward " \t\n") |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1515 (< (point) here) (sgml-at-indentation-p)) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1516 (current-column)) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1517 (t |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1518 (goto-char there) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1519 (+ (current-column) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1520 (* sgml-basic-offset (length context))))))) |
47933
b5ddbda34d8e
(sgml-close-tag, html-imenu-index): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47679
diff
changeset
|
1521 |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1522 (otherwise |
63521
0f90f64f45d8
(sgml-calculate-indent, html-tag-help): Fix spellings.
Juanma Barranquero <lekktu@gmail.com>
parents:
63226
diff
changeset
|
1523 (error "Unrecognized context %s" (car lcon))) |
44286
1d7ee8515c45
Add an explicit check for 'text syntax, to protect against future
Mike Williams <mdub@bigfoot.com>
parents:
44244
diff
changeset
|
1524 |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1525 )) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1526 |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1527 (defun sgml-indent-line () |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1528 "Indent the current line as SGML." |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1529 (interactive) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1530 (let* ((savep (point)) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1531 (indent-col |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1532 (save-excursion |
44241
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1533 (back-to-indentation) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1534 (if (>= (point) savep) (setq savep nil)) |
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1535 (sgml-calculate-indent)))) |
51478
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1536 (if (null indent-col) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1537 'noindent |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1538 (if savep |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1539 (save-excursion (indent-line-to indent-col)) |
cc38ef483a77
(sgml-parse-tag-backward): Try and detect
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50955
diff
changeset
|
1540 (indent-line-to indent-col))))) |
44200
3ea526b58b9e
(sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43979
diff
changeset
|
1541 |
44502
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1542 (defun sgml-guess-indent () |
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1543 "Guess an appropriate value for `sgml-basic-offset'. |
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1544 Base the guessed identation level on the first indented tag in the buffer. |
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1545 Add this to `sgml-mode-hook' for convenience." |
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1546 (interactive) |
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1547 (save-excursion |
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1548 (goto-char (point-min)) |
45463
62d5e10140e7
(sgml-guess-indent): Look further into the buffer.
Mike Williams <mdub@bigfoot.com>
parents:
45286
diff
changeset
|
1549 (if (re-search-forward "^\\([ \t]+\\)<" 500 'noerror) |
44502
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1550 (progn |
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1551 (set (make-local-variable 'sgml-basic-offset) |
47679
96093793b6b4
(sgml-guess-indent): Handle tabs correctly.
Mike Williams <mdub@bigfoot.com>
parents:
46352
diff
changeset
|
1552 (1- (current-column))) |
44502
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1553 (message "Guessed sgml-basic-offset = %d" |
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1554 sgml-basic-offset) |
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1555 )))) |
4067d1e7f884
(sgml-guess-indent): New function.
Mike Williams <mdub@bigfoot.com>
parents:
44460
diff
changeset
|
1556 |
44241
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1557 (defun sgml-parse-dtd () |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1558 "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
|
1559 Currently just returns (EMPTY-TAGS UNCLOSED-TAGS)." |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1560 (goto-char (point-min)) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1561 (let ((empty nil) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1562 (unclosed nil)) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1563 (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
|
1564 (cond |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1565 ((string= (match-string 3) "EMPTY") |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1566 (push (match-string-no-properties 1) empty)) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1567 ((string= (match-string 2) "O") |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1568 (push (match-string-no-properties 1) unclosed)))) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1569 (setq empty (sort (mapcar 'downcase empty) 'string<)) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1570 (setq unclosed (sort (mapcar 'downcase unclosed) 'string<)) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1571 (list empty unclosed))) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1572 |
38068
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
1573 ;;; HTML mode |
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
1574 |
25175 | 1575 (defcustom html-mode-hook nil |
1576 "Hook run by command `html-mode'. | |
1577 `text-mode-hook' and `sgml-mode-hook' are run first." | |
1578 :group 'sgml | |
1579 :type 'hook | |
1580 :options '(html-autoview-mode)) | |
1581 | |
14270
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1582 (defvar html-quick-keys sgml-quick-keys |
14377 | 1583 "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
|
1584 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
|
1585 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
|
1586 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1587 (defvar html-mode-map |
37252
5db39c2eba1e
Add unknown maintainer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36609
diff
changeset
|
1588 (let ((map (make-sparse-keymap)) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1589 (menu-map (make-sparse-keymap "HTML"))) |
37252
5db39c2eba1e
Add unknown maintainer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36609
diff
changeset
|
1590 (set-keymap-parent map sgml-mode-map) |
15437
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
1591 (define-key map "\C-c6" 'html-headline-6) |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
1592 (define-key map "\C-c5" 'html-headline-5) |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
1593 (define-key map "\C-c4" 'html-headline-4) |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
1594 (define-key map "\C-c3" 'html-headline-3) |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
1595 (define-key map "\C-c2" 'html-headline-2) |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
1596 (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
|
1597 (define-key map "\C-c\r" 'html-paragraph) |
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1598 (define-key map "\C-c\n" 'html-line) |
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1599 (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
|
1600 (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
|
1601 (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
|
1602 (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
|
1603 (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
|
1604 (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
|
1605 (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
|
1606 (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
|
1607 (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
|
1608 (when html-quick-keys |
25129ef47b45
some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents:
40320
diff
changeset
|
1609 (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
|
1610 (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
|
1611 (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
|
1612 (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
|
1613 (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
|
1614 (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
|
1615 (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
|
1616 (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
|
1617 (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
|
1618 (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
|
1619 (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
|
1620 (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
|
1621 (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
|
1622 '("Toggle Autoviewing" . html-autoview-mode)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1623 (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
|
1624 '("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
|
1625 (define-key menu-map [nil] '("--")) |
15437
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
1626 ;;(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
|
1627 ;;(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
|
1628 ;;(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
|
1629 (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
|
1630 (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
|
1631 (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
|
1632 (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
|
1633 (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
|
1634 (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
|
1635 (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
|
1636 (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
|
1637 (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
|
1638 (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
|
1639 (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
|
1640 (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
|
1641 (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
|
1642 (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
|
1643 map) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1644 "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
|
1645 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1646 (defvar html-face-tag-alist |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1647 '((bold . "b") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1648 (italic . "i") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1649 (underline . "u") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1650 (modeline . "rev")) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1651 "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
|
1652 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1653 (defvar html-tag-face-alist |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1654 '(("b" . bold) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1655 ("big" . bold) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1656 ("blink" . highlight) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1657 ("cite" . italic) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1658 ("em" . italic) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1659 ("h1" bold underline) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1660 ("h2" bold-italic underline) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1661 ("h3" italic underline) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1662 ("h4" . underline) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1663 ("h5" . underline) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1664 ("h6" . underline) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1665 ("i" . italic) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1666 ("rev" . modeline) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1667 ("s" . underline) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1668 ("small" . default) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1669 ("strong" . bold) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1670 ("title" bold underline) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1671 ("tt" . default) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1672 ("u" . underline) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1673 ("var" . italic)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1674 "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
|
1675 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1676 (defvar html-display-text |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1677 '((img . "[/]") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1678 (hr . "----------") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1679 (li . "o ")) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1680 "Value of `sgml-display-text' for HTML mode.") |
44459
25c3c51b0375
(sgml-tag-alist): Doc fix.
Mike Williams <mdub@bigfoot.com>
parents:
44443
diff
changeset
|
1681 |
22629
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
1682 |
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
1683 ;; 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
|
1684 (defvar html-tag-alist |
17545
c67787f92aea
(sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents:
17530
diff
changeset
|
1685 (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
|
1686 (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
|
1687 (align '(("align" ("left") ("center") ("right")))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1688 (valign '(("top") ("middle") ("bottom") ("baseline"))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1689 (rel '(("next") ("previous") ("parent") ("subdocument") ("made"))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1690 (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
|
1691 ("mailto:") ("news:") ("rlogin:") ("telnet:") ("tn3270:") |
14270
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1692 ("wais:") ("/cgi-bin/"))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1693 (name '("name")) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1694 (link `(,href |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1695 ("rel" ,@rel) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1696 ("rev" ,@rel) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1697 ("title"))) |
39616
13a1b8cf5135
added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents:
38431
diff
changeset
|
1698 (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
|
1699 (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
|
1700 (cell `(t |
38068
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
1701 ,@align |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1702 ("valign" ,@valign) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1703 ("colspan" ,@1-9) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1704 ("rowspan" ,@1-9) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1705 ("nowrap" t)))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1706 ;; 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
|
1707 ;; 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
|
1708 `(("a" ,name ,@link) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1709 ("base" t ,@href) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1710 ("dir" ,@list) |
17545
c67787f92aea
(sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents:
17530
diff
changeset
|
1711 ("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
|
1712 ("form" (\n _ \n "<input type=\"submit\" value=\"\"" |
60521 | 1713 (if sgml-xml-mode " />" ">")) |
14270
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1714 ("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
|
1715 ("h1" ,@align) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1716 ("h2" ,@align) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1717 ("h3" ,@align) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1718 ("h4" ,@align) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1719 ("h5" ,@align) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1720 ("h6" ,@align) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1721 ("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
|
1722 ("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
|
1723 ("src") ("alt") ("width" "1") ("height" "1") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1724 ("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
|
1725 ("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
|
1726 ("type" ("text") ("password") ("checkbox") ("radio") |
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1727 ("submit") ("reset")) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1728 ("value")) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1729 ("link" t ,@link) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1730 ("menu" ,@list) |
17545
c67787f92aea
(sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents:
17530
diff
changeset
|
1731 ("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
|
1732 ("p" t ,@align) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1733 ("select" (nil \n |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1734 ("Text: " |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
1735 "<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
|
1736 ,name ("size" ,@1-9) ("multiple" t)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1737 ("table" (nil \n |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1738 ((completing-read "Cell kind: " '(("td") ("th")) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1739 nil t "t") |
40392
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
1740 "<tr><" str ?> _ |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
1741 (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
|
1742 ("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
|
1743 ("td" ,@cell) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1744 ("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
|
1745 ("th" ,@cell) |
17545
c67787f92aea
(sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents:
17530
diff
changeset
|
1746 ("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
|
1747 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1748 ,@sgml-tag-alist |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1749 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1750 ("abbrev") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1751 ("acronym") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1752 ("address") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1753 ("array" (nil \n |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
1754 ("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
|
1755 "align") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1756 ("au") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1757 ("b") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1758 ("big") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1759 ("blink") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1760 ("blockquote" \n) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1761 ("body" \n ("background" ".gif") ("bgcolor" "#") ("text" "#") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1762 ("link" "#") ("alink" "#") ("vlink" "#")) |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
1763 ("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
|
1764 ("br" t ("clear" ("left") ("right"))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1765 ("caption" ("valign" ("top") ("bottom"))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1766 ("center" \n) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1767 ("cite") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1768 ("code" \n) |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
1769 ("dd" ,(not sgml-xml-mode)) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1770 ("del") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1771 ("dfn") |
38068
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
1772 ("div") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1773 ("dl" (nil \n |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1774 ( "Term: " |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
1775 "<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
|
1776 "<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
|
1777 ("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
|
1778 "<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
|
1779 ("em") |
105662
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1780 ("fn" "id" "fn") ;; Footnotes were deprecated in HTML 3.2 |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1781 ("head" \n) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1782 ("html" (\n |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1783 "<head>\n" |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1784 "<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
|
1785 "</head>\n" |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1786 "<body>\n<h1>" str "</h1>\n" _ |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1787 "\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
|
1788 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
|
1789 "\">" (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
|
1790 "</body>" |
e2c5b1571392
(html-tag-alist): Add /head and /body to the "html" template.
Richard M. Stallman <rms@gnu.org>
parents:
23970
diff
changeset
|
1791 )) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1792 ("i") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1793 ("ins") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1794 ("isindex" t ("action") ("prompt")) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1795 ("kbd") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1796 ("lang") |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
1797 ("li" ,(not sgml-xml-mode)) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1798 ("math" \n) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1799 ("nobr") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1800 ("option" t ("value") ("label") ("selected" t)) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1801 ("over" t) |
105662
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1802 ("person") ;; Tag for person's name tag deprecated in HTML 3.2 |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1803 ("pre" \n) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1804 ("q") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1805 ("rev") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1806 ("s") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1807 ("samp") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1808 ("small") |
40320
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1809 ("span" nil |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1810 ("class" |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1811 ("builtin") |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1812 ("comment") |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1813 ("constant") |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1814 ("function-name") |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1815 ("keyword") |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1816 ("string") |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1817 ("type") |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1818 ("variable-name") |
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1819 ("warning"))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1820 ("strong") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1821 ("sub") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1822 ("sup") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1823 ("title") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1824 ("tr" t) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1825 ("tt") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1826 ("u") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1827 ("var") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1828 ("wbr" t))) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1829 "*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
|
1830 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1831 (defvar html-tag-help |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1832 `(,@sgml-tag-help |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1833 ("a" . "Anchor of point or link elsewhere") |
105662
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1834 ("abbrev" . "Abbreviation") |
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1835 ("acronym" . "Acronym") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1836 ("address" . "Formatted mail address") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1837 ("array" . "Math array") |
105662
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1838 ("au" . "Author") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1839 ("b" . "Bold face") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1840 ("base" . "Base address for URLs") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1841 ("big" . "Font size") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1842 ("blink" . "Blinking text") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1843 ("blockquote" . "Indented quotation") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1844 ("body" . "Document body") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1845 ("box" . "Math fraction") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1846 ("br" . "Line break") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1847 ("caption" . "Table caption") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1848 ("center" . "Centered text") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1849 ("changed" . "Change bars") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1850 ("cite" . "Citation of a document") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1851 ("code" . "Formatted source code") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1852 ("dd" . "Definition of term") |
105662
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1853 ("del" . "Deleted text") |
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1854 ("dfn" . "Defining instance of a term") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1855 ("dir" . "Directory list (obsolete)") |
105662
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1856 ("div" . "Generic block-level container") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1857 ("dl" . "Definition list") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1858 ("dt" . "Term to be definined") |
63521
0f90f64f45d8
(sgml-calculate-indent, html-tag-help): Fix spellings.
Juanma Barranquero <lekktu@gmail.com>
parents:
63226
diff
changeset
|
1859 ("em" . "Emphasized") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1860 ("embed" . "Embedded data in foreign format") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1861 ("fig" . "Figure") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1862 ("figa" . "Figure anchor") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1863 ("figd" . "Figure description") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1864 ("figt" . "Figure text") |
105662
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1865 ("fn" . "Footnote") ;; No one supports special footnote rendering. |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1866 ("font" . "Font size") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1867 ("form" . "Form with input fields") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1868 ("group" . "Document grouping") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1869 ("h1" . "Most important section headline") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1870 ("h2" . "Important section headline") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1871 ("h3" . "Section headline") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1872 ("h4" . "Minor section headline") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1873 ("h5" . "Unimportant section headline") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1874 ("h6" . "Least important section headline") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1875 ("head" . "Document header") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1876 ("hr" . "Horizontal rule") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1877 ("html" . "HTML Document") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1878 ("i" . "Italic face") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1879 ("img" . "Graphic image") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1880 ("input" . "Form input field") |
105662
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1881 ("ins" . "Inserted text") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1882 ("isindex" . "Input field for index search") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1883 ("kbd" . "Keybard example face") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1884 ("lang" . "Natural language") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1885 ("li" . "List item") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1886 ("link" . "Link relationship") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1887 ("math" . "Math formula") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1888 ("menu" . "Menu list (obsolete)") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1889 ("mh" . "Form mail header") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1890 ("nextid" . "Allocate new id") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1891 ("nobr" . "Text without line break") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1892 ("ol" . "Ordered list") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1893 ("option" . "Selection list item") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1894 ("over" . "Math fraction rule") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1895 ("p" . "Paragraph start") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1896 ("panel" . "Floating panel") |
105662
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1897 ("person" . "Person's name") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1898 ("pre" . "Preformatted fixed width text") |
105662
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1899 ("q" . "Quotation") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1900 ("rev" . "Reverse video") |
105662
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1901 ("s" . "Strikeout") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1902 ("samp" . "Sample text") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1903 ("select" . "Selection list") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1904 ("small" . "Font size") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1905 ("sp" . "Nobreak space") |
105662
5784286c9609
* textmodes/sgml-mode.el (sgml-tag-help): Prompt user for tag.
Chong Yidong <cyd@stupidchicken.com>
parents:
105187
diff
changeset
|
1906 ("span" . "Generic inline container") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1907 ("strong" . "Standout text") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1908 ("sub" . "Subscript") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1909 ("sup" . "Superscript") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1910 ("table" . "Table with rows and columns") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1911 ("tb" . "Table vertical break") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1912 ("td" . "Table data cell") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1913 ("textarea" . "Form multiline edit area") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1914 ("th" . "Table header cell") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1915 ("title" . "Document title") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1916 ("tr" . "Table row separator") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1917 ("tt" . "Typewriter face") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1918 ("u" . "Underlined text") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1919 ("ul" . "Unordered list") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1920 ("var" . "Math variable face") |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1921 ("wbr" . "Enable <br> within <nobr>")) |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
1922 "*Value of `sgml-tag-help' for HTML mode.") |
44459
25c3c51b0375
(sgml-tag-alist): Doc fix.
Mike Williams <mdub@bigfoot.com>
parents:
44443
diff
changeset
|
1923 |
22629
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
1924 |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1925 ;;;###autoload |
81456
2be88db9aeed
(sgml-xml-guess): Return the result rather than setting sgml-xml-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81097
diff
changeset
|
1926 (define-derived-mode html-mode sgml-mode '(sgml-xml-mode "XHTML" "HTML") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1927 "Major mode based on SGML mode for editing HTML documents. |
23652 | 1928 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
|
1929 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
|
1930 \\[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
|
1931 which this is based. |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1932 |
14270
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1933 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
|
1934 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1935 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
|
1936 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
|
1937 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
|
1938 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
|
1939 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1940 <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
|
1941 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
|
1942 <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
|
1943 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1944 <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
|
1945 ignored unless the text is <pre>preformatted.</pre> Text can be marked as |
61014
9a8eaf5d664a
(html-mode): Doc update.
Luc Teirlinck <teirllm@auburn.edu>
parents:
60521
diff
changeset
|
1946 <b>bold</b>, <i>italic</i> or <u>underlined</u> using the normal M-o or |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1947 Edit/Text Properties/Face commands. |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1948 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1949 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
|
1950 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
|
1951 href=\"URL\">see also URL</a> where URL is a filename relative to current |
17551 | 1952 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
|
1953 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1954 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
|
1955 |
17551 | 1956 If you mainly create your own documents, `sgml-specials' might be |
1957 interesting. But note that some HTML 2 browsers can't handle `''. | |
1958 To work around that, do: | |
1959 (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
|
1960 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1961 \\{html-mode-map}" |
40320
66ba1d523634
(sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40176
diff
changeset
|
1962 (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
|
1963 (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
|
1964 (make-local-variable 'sgml-tag-alist) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1965 (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
|
1966 (make-local-variable 'sgml-tag-help) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1967 (make-local-variable 'outline-regexp) |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1968 (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
|
1969 (make-local-variable 'outline-level) |
68223
69be9c945c82
Add `coding: iso-2022-7bit' cookie.
Juri Linkov <juri@jurta.org>
parents:
66963
diff
changeset
|
1970 (make-local-variable 'sentence-end-base) |
104325
c730723a8c88
Change to utf-8. Adjust coding cookie.
Kenichi Handa <handa@m17n.org>
parents:
101003
diff
changeset
|
1971 (setq sentence-end-base "[.?!][]\"'”)}]*\\(<[^>]*>\\)*" |
68223
69be9c945c82
Add `coding: iso-2022-7bit' cookie.
Juri Linkov <juri@jurta.org>
parents:
66963
diff
changeset
|
1972 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
|
1973 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
|
1974 sgml-tag-help html-tag-help |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1975 outline-regexp "^.*<[Hh][1-6]\\>" |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
1976 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
|
1977 outline-level (lambda () |
43692
568974ab1796
Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43589
diff
changeset
|
1978 (char-before (match-end 0)))) |
22629
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
1979 (setq imenu-create-index-function 'html-imenu-index) |
40392
e4b72489cdc4
(sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40377
diff
changeset
|
1980 (set (make-local-variable 'sgml-empty-tags) |
44241
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1981 ;; 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
|
1982 ;; plus manual addition of "wbr". |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1983 '("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
|
1984 "isindex" "link" "meta" "param" "wbr")) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1985 (set (make-local-variable 'sgml-unclosed-tags) |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1986 ;; 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
|
1987 '("body" "colgroup" "dd" "dt" "head" "html" "li" "option" |
600b7e53cf18
(sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44200
diff
changeset
|
1988 "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
|
1989 ;; 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
|
1990 ;; (make-local-variable 'imenu-sort-function) |
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
1991 ;; (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
|
1992 ) |
44459
25c3c51b0375
(sgml-tag-alist): Doc fix.
Mike Williams <mdub@bigfoot.com>
parents:
44443
diff
changeset
|
1993 |
22629
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
1994 (defvar html-imenu-regexp |
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
1995 "\\s-*<h\\([1-9]\\)[^\n<>]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)" |
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
1996 "*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
|
1997 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
|
1998 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
|
1999 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
|
2000 |
22629
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
2001 (defun html-imenu-index () |
47933
b5ddbda34d8e
(sgml-close-tag, html-imenu-index): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
47679
diff
changeset
|
2002 "Return a table of contents for an HTML buffer for use with Imenu." |
22629
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
2003 (let (toc-index) |
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
2004 (save-excursion |
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
2005 (goto-char (point-min)) |
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
2006 (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
|
2007 (setq toc-index |
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
2008 (cons (cons (concat (make-string |
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
2009 (* 2 (1- (string-to-number (match-string 1)))) |
64058
7e00d33823d3
(sgml): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
63521
diff
changeset
|
2010 ?\s) |
22629
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
2011 (match-string 3)) |
40343
25129ef47b45
some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents:
40320
diff
changeset
|
2012 (line-beginning-position)) |
22629
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
2013 toc-index)))) |
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
2014 (nreverse toc-index))) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2015 |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
2016 (define-minor-mode html-autoview-mode |
25175 | 2017 "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
|
2018 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
|
2019 Can be used as a value for `html-mode-hook'." |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
2020 nil nil nil |
48402
f4682f3c8e03
(html-autoview-mode): Add group.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
48262
diff
changeset
|
2021 :group 'sgml |
48262
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
2022 (if html-autoview-mode |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
2023 (add-hook 'after-save-hook 'browse-url-of-buffer nil t) |
1ef1bf10c03c
(sgml-namify-char): New cmd.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48109
diff
changeset
|
2024 (remove-hook 'after-save-hook 'browse-url-of-buffer t))) |
44459
25c3c51b0375
(sgml-tag-alist): Doc fix.
Mike Williams <mdub@bigfoot.com>
parents:
44443
diff
changeset
|
2025 |
22629
5d51b13e0d1f
(html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents:
22319
diff
changeset
|
2026 |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2027 (define-skeleton html-href-anchor |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2028 "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
|
2029 "URL: " |
60521 | 2030 ;; '(setq input "http:") |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2031 "<a href=\"" str "\">" _ "</a>") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2032 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2033 (define-skeleton html-name-anchor |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2034 "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
|
2035 "Name: " |
60521 | 2036 "<a name=\"" str "\"" |
2037 (if sgml-xml-mode (concat " id=\"" str "\"")) | |
2038 ">" _ "</a>") | |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2039 |
15437
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2040 (define-skeleton html-headline-1 |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2041 "HTML level 1 headline tags." |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2042 nil |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2043 "<h1>" _ "</h1>") |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2044 |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2045 (define-skeleton html-headline-2 |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2046 "HTML level 2 headline tags." |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2047 nil |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2048 "<h2>" _ "</h2>") |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2049 |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2050 (define-skeleton html-headline-3 |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2051 "HTML level 3 headline tags." |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2052 nil |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2053 "<h3>" _ "</h3>") |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2054 |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2055 (define-skeleton html-headline-4 |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2056 "HTML level 4 headline tags." |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2057 nil |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2058 "<h4>" _ "</h4>") |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2059 |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2060 (define-skeleton html-headline-5 |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2061 "HTML level 5 headline tags." |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2062 nil |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2063 "<h5>" _ "</h5>") |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2064 |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2065 (define-skeleton html-headline-6 |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2066 "HTML level 6 headline tags." |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2067 nil |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2068 "<h6>" _ "</h6>") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2069 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2070 (define-skeleton html-horizontal-rule |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2071 "HTML horizontal rule tag." |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2072 nil |
60521 | 2073 (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
|
2074 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2075 (define-skeleton html-image |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2076 "HTML image tag." |
60521 | 2077 "Image URL: " |
2078 "<img src=\"" str "\" alt=\"" _ "\"" | |
2079 (if sgml-xml-mode " />" ">")) | |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2080 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2081 (define-skeleton html-line |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2082 "HTML line break tag." |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2083 nil |
60521 | 2084 (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
|
2085 |
15437
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2086 (define-skeleton html-ordered-list |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2087 "HTML ordered list tags." |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2088 nil |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2089 "<ol>" \n |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
2090 "<li>" _ (if sgml-xml-mode "</li>") \n |
15437
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2091 "</ol>") |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2092 |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2093 (define-skeleton html-unordered-list |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2094 "HTML unordered list tags." |
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2095 nil |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2096 "<ul>" \n |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
2097 "<li>" _ (if sgml-xml-mode "</li>") \n |
15437
43b1f8a3af53
(html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents:
14518
diff
changeset
|
2098 "</ul>") |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2099 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2100 (define-skeleton html-list-item |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2101 "HTML list item tag." |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2102 nil |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2103 (if (bolp) nil '\n) |
43979
6dff5806cdcd
(sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43692
diff
changeset
|
2104 "<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
|
2105 |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2106 (define-skeleton html-paragraph |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2107 "HTML paragraph tag." |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2108 nil |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2109 (if (bolp) nil ?\n) |
60521 | 2110 "<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
|
2111 |
14270
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
2112 (define-skeleton html-checkboxes |
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
2113 "Group of connected checkbox inputs." |
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
2114 nil |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2115 '(setq v1 nil |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2116 v2 nil) |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2117 ("Value: " |
17545
c67787f92aea
(sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents:
17530
diff
changeset
|
2118 "<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
|
2119 "\" 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
|
2120 "\" value=\"" str ?\" |
39616
13a1b8cf5135
added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents:
38431
diff
changeset
|
2121 (when (y-or-n-p "Set \"checked\" attribute? ") |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
2122 (funcall skeleton-transformation-function |
60521 | 2123 (if sgml-xml-mode " checked=\"checked\"" " checked"))) |
2124 (if sgml-xml-mode " />" ">") | |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2125 (skeleton-read "Text: " (capitalize str)) |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2126 (or v2 (setq v2 (if (y-or-n-p "Newline after text? ") |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
2127 (funcall skeleton-transformation-function |
60521 | 2128 (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
|
2129 ""))) |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2130 \n)) |
14270
15c3d6255a1c
(sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
2131 |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2132 (define-skeleton html-radio-buttons |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2133 "Group of connected radio button inputs." |
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2134 nil |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2135 '(setq v1 nil |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2136 v2 (cons nil nil)) |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2137 ("Value: " |
17545
c67787f92aea
(sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents:
17530
diff
changeset
|
2138 "<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
|
2139 "\" 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
|
2140 "\" value=\"" str ?\" |
39616
13a1b8cf5135
added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents:
38431
diff
changeset
|
2141 (when (and (not v1) (setq v1 (y-or-n-p "Set \"checked\" attribute? "))) |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
2142 (funcall skeleton-transformation-function |
60521 | 2143 (if sgml-xml-mode " checked=\"checked\"" " checked"))) |
2144 (if sgml-xml-mode " />" ">") | |
17491
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2145 (skeleton-read "Text: " (capitalize str)) |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2146 (or (cdr v2) (setcdr v2 (if (y-or-n-p "Newline after text? ") |
70823
ca1b3788f58d
(sgml-transformation): Make this the alias for the following variable.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
68648
diff
changeset
|
2147 (funcall skeleton-transformation-function |
60521 | 2148 (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
|
2149 ""))) |
4c6505ca34a7
(sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents:
17433
diff
changeset
|
2150 \n)) |
14159
93175ed23e01
Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
2151 |
38068
e3bd229672c1
Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37252
diff
changeset
|
2152 (provide 'sgml-mode) |
38431
853c3674f20a
Fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38108
diff
changeset
|
2153 |
58122
1e9ea828c37a
(sgml-tag-text-p): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57718
diff
changeset
|
2154 ;; arch-tag: 9675da94-b7f9-4bda-ad19-73ed7b4fb401 |
809 | 2155 ;;; sgml-mode.el ends here |