annotate lisp/nxml/nxml-mode.el @ 112427:bc872de587fa

* play/landmark.el: Change `lm-' prefix to `landmark-' (Bug#7672). (lm): Rename to landmark. (lm-test-run): Rename to landmark-test-run.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 22 Jan 2011 15:12:51 -0500
parents 61f7601898b1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1 ;;; nxml-mode.el --- a new XML mode
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2
112284
61f7601898b1 Refill some copyright headers.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
3 ;; Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011
61f7601898b1 Refill some copyright headers.
Glenn Morris <rgm@gnu.org>
parents: 112228
diff changeset
4 ;; Free Software Foundation, Inc.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
5
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
6 ;; Author: James Clark
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
7 ;; Keywords: XML
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
8
86538
57f0d08e5bbe Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
9 ;; This file is part of GNU Emacs.
57f0d08e5bbe Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
10
94666
d495d4d5452f Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93917
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
86538
57f0d08e5bbe Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94666
d495d4d5452f Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93917
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
d495d4d5452f Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93917
diff changeset
14 ;; (at your option) any later version.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
15
86538
57f0d08e5bbe Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
57f0d08e5bbe Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
57f0d08e5bbe Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57f0d08e5bbe Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
19 ;; GNU General Public License for more details.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
20
86538
57f0d08e5bbe Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94666
d495d4d5452f Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93917
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
23
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
24 ;;; Commentary:
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
25
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
26 ;; See nxml-rap.el for description of parsing strategy.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
27
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
28 ;;; Code:
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
29
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
30 (when (featurep 'mucs)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
31 (error "nxml-mode is not compatible with Mule-UCS"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
32
96182
b14adb1a6079 Require 'cl when compiling.
Glenn Morris <rgm@gnu.org>
parents: 96007
diff changeset
33 (eval-when-compile (require 'cl)) ; for assert
b14adb1a6079 Require 'cl when compiling.
Glenn Morris <rgm@gnu.org>
parents: 96007
diff changeset
34
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
35 (require 'xmltok)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
36 (require 'nxml-enc)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
37 (require 'nxml-glyph)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
38 (require 'nxml-util)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
39 (require 'nxml-rap)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
40 (require 'nxml-outln)
111802
ec305a5ef324 Silence nxml-mode.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111801
diff changeset
41 ;; nxml-mode calls rng-nxml-mode-init, which is autoloaded from rng-nxml.
ec305a5ef324 Silence nxml-mode.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111801
diff changeset
42 ;; So we might as well just require it and silence the compiler.
ec305a5ef324 Silence nxml-mode.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111801
diff changeset
43 (provide 'nxml-mode) ; avoid recursive require
ec305a5ef324 Silence nxml-mode.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111801
diff changeset
44 (require 'rng-nxml)
87719
a38e332c61af (nxml-enable-unicode-char-name-sets, rng-nxml-mode-init): Declare.
Jason Rumney <jasonr@gnu.org>
parents: 87715
diff changeset
45
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
46 ;;; Customization
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
47
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
48 (defgroup nxml nil
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
49 "New XML editing mode."
107378
904ccd8f2acb Reorganize Custom groups.
Chong Yidong <cyd@stupidchicken.com>
parents: 107167
diff changeset
50 :group 'languages)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
51
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
52 (defgroup nxml-faces nil
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
53 "Faces for XML syntax highlighting."
107167
f6b8c73548b3 Minor tweaks to custom groups.
Chong Yidong <cyd@stupidchicken.com>
parents: 106873
diff changeset
54 :group 'nxml)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
55
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
56 (defcustom nxml-char-ref-display-glyph-flag t
111801
c06fec785962 Remove leading `*' from nxml defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 111782
diff changeset
57 "Non-nil means display glyph following character reference.
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
58 The glyph is displayed in face `nxml-glyph'. The hook
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
59 `nxml-glyph-set-hook' can be used to customize for which characters
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
60 glyphs are displayed."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
61 :group 'nxml
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
62 :type 'boolean)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
63
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
64 (defcustom nxml-sexp-element-flag nil
111801
c06fec785962 Remove leading `*' from nxml defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 111782
diff changeset
65 "Non-nil means sexp commands treat an element as a single expression."
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
66 :group 'nxml
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
67 :type 'boolean)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
68
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
69 (defcustom nxml-slash-auto-complete-flag nil
111801
c06fec785962 Remove leading `*' from nxml defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 111782
diff changeset
70 "Non-nil means typing a slash automatically completes the end-tag.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
71 This is used by `nxml-electric-slash'."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
72 :group 'nxml
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
73 :type 'boolean)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
74
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
75 (defcustom nxml-child-indent 2
111801
c06fec785962 Remove leading `*' from nxml defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 111782
diff changeset
76 "Indentation for the children of an element relative to the start-tag.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
77 This only applies when the line or lines containing the start-tag contains
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
78 nothing else other than that start-tag."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
79 :group 'nxml
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
80 :type 'integer)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
81
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
82 (defcustom nxml-attribute-indent 4
111801
c06fec785962 Remove leading `*' from nxml defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 111782
diff changeset
83 "Indentation for the attributes of an element relative to the start-tag.
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
84 This only applies when the first attribute of a tag starts a line.
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
85 In other cases, the first attribute on one line is indented the same
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
86 as the first attribute on the previous line."
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
87 :group 'nxml
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
88 :type 'integer)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
89
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
90 (defcustom nxml-bind-meta-tab-to-complete-flag (not window-system)
111801
c06fec785962 Remove leading `*' from nxml defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 111782
diff changeset
91 "Non-nil means bind M-TAB in `nxml-mode-map' to `nxml-complete'.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
92 C-return will be bound to `nxml-complete' in any case.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
93 M-TAB gets swallowed by many window systems/managers, and
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
94 `documentation' will show M-TAB rather than C-return as the
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
95 binding for `nxml-complete' when both are bound. So it's better
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
96 to bind M-TAB only when it will work."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
97 :group 'nxml
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
98 :set (lambda (sym flag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
99 (set-default sym flag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
100 (when (and (boundp 'nxml-mode-map) nxml-mode-map)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
101 (define-key nxml-mode-map "\M-\t" (and flag 'nxml-complete))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
102 :type 'boolean)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
103
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
104 (defcustom nxml-prefer-utf-16-to-utf-8-flag nil
111801
c06fec785962 Remove leading `*' from nxml defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 111782
diff changeset
105 "Non-nil means prefer UTF-16 to UTF-8 when saving a buffer.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
106 This is used only when a buffer does not contain an encoding declaration
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
107 and when its current `buffer-file-coding-system' specifies neither UTF-16
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
108 nor UTF-8."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
109 :group 'nxml
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
110 :type 'boolean)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
111
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
112 (defcustom nxml-prefer-utf-16-little-to-big-endian-flag (eq system-type
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
113 'windows-nt)
111801
c06fec785962 Remove leading `*' from nxml defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 111782
diff changeset
114 "Non-nil means prefer little-endian to big-endian byte-order for UTF-16.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
115 This is used only for saving a buffer; when reading the byte-order is
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
116 auto-detected. It may be relevant both when there is no encoding declaration
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
117 and when the encoding declaration specifies `UTF-16'."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
118 :group 'nxml
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
119 :type 'boolean)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
120
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
121 (defcustom nxml-default-buffer-file-coding-system nil
111801
c06fec785962 Remove leading `*' from nxml defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 111782
diff changeset
122 "Default value for `buffer-file-coding-system' for a buffer for a new file.
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
123 A value of nil means use the default value of `buffer-file-coding-system' as normal.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
124 A buffer's `buffer-file-coding-system' affects what \\[nxml-insert-xml-declaration] inserts."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
125 :group 'nxml
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
126 :type 'coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
127
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
128 (defcustom nxml-auto-insert-xml-declaration-flag nil
111801
c06fec785962 Remove leading `*' from nxml defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 111782
diff changeset
129 "Non-nil means automatically insert an XML declaration in a new file.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
130 The XML declaration is inserted using `nxml-insert-xml-declaration'."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
131 :group 'nxml
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
132 :type 'boolean)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
133
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
134 (defface nxml-delimited-data
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
135 '((t (:inherit font-lock-doc-face)))
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
136 "Face used to highlight data enclosed between delimiters.
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
137 This is not used directly, but only via inheritance by other faces."
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
138 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
139
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
140 (defface nxml-name
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
141 '((t (:inherit font-lock-builtin-face)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
142 "Face used to highlight various names.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
143 This includes element and attribute names, processing
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
144 instruction targets and the CDATA keyword in a CDATA section.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
145 This is not used directly, but only via inheritance by other faces."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
146 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
147
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
148 (defface nxml-ref
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
149 '((t (:inherit font-lock-constant-face)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
150 "Face used to highlight character and entity references.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
151 This is not used directly, but only via inheritance by other faces."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
152 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
153
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
154 (defface nxml-delimiter
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
155 nil
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
156 "Face used to highlight delimiters.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
157 This is not used directly, but only via inheritance by other faces."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
158 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
159
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
160 (defface nxml-text
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
161 nil
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
162 "Face used to highlight text."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
163 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
164
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
165 (defface nxml-comment-content
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
166 '((t (:inherit font-lock-comment-face)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
167 "Face used to highlight the content of comments."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
168 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
169
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
170 (defface nxml-comment-delimiter
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
171 '((t (:inherit font-lock-comment-delimiter-face)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
172 "Face used for the delimiters of comments, i.e <!-- and -->."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
173 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
174
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
175 (defface nxml-processing-instruction-delimiter
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
176 '((t (:inherit nxml-delimiter)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
177 "Face used for the delimiters of processing instructions, i.e <? and ?>."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
178 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
179
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
180 (defface nxml-processing-instruction-target
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
181 '((t (:inherit font-lock-keyword-face)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
182 "Face used for the target of processing instructions."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
183 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
184
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
185 (defface nxml-processing-instruction-content
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
186 '((t (:inherit nxml-delimited-data)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
187 "Face used for the content of processing instructions."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
188 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
189
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
190 (defface nxml-cdata-section-delimiter
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
191 '((t (:inherit nxml-delimiter)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
192 "Face used for the delimiters of CDATA sections, i.e <![, [, and ]]>."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
193 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
194
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
195 (defface nxml-cdata-section-CDATA
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
196 '((t (:inherit nxml-name)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
197 "Face used for the CDATA keyword in CDATA sections."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
198 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
199
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
200 (defface nxml-cdata-section-content
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
201 '((t (:inherit nxml-text)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
202 "Face used for the content of CDATA sections."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
203 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
204
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
205 (defface nxml-char-ref-number
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
206 '((t (:inherit nxml-ref)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
207 "Face used for the number in character references.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
208 This includes ths `x' in hex references."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
209 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
210
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
211 (defface nxml-char-ref-delimiter
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
212 '((t (:inherit nxml-ref)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
213 "Face used for the delimiters of character references, i.e &# and ;."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
214 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
215
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
216 (defface nxml-entity-ref-name
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
217 '((t (:inherit nxml-ref)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
218 "Face used for the entity name in general entity references."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
219 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
220
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
221 (defface nxml-entity-ref-delimiter
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
222 '((t (:inherit nxml-ref)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
223 "Face used for the delimiters of entity references, i.e & and ;."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
224 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
225
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
226 (defface nxml-tag-delimiter
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
227 '((t (:inherit nxml-delimiter)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
228 "Face used for the angle brackets delimiting tags.
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
229 `nxml-tag-slash' is used for slashes."
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
230 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
231
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
232 (defface nxml-tag-slash
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
233 '((t (:inherit nxml-tag-delimiter)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
234 "Face used for slashes in tags, both in end-tags and empty-elements."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
235 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
236
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
237 (defface nxml-element-prefix
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
238 '((t (:inherit nxml-name)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
239 "Face used for the prefix of elements."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
240 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
241
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
242 (defface nxml-element-colon
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
243 nil
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
244 "Face used for the colon in element names."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
245 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
246
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
247 (defface nxml-element-local-name
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
248 '((t (:inherit font-lock-function-name-face)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
249 "Face used for the local name of elements."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
250 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
251
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
252 (defface nxml-attribute-prefix
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
253 '((t (:inherit nxml-name)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
254 "Face used for the prefix of attributes."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
255 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
256
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
257 (defface nxml-attribute-colon
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
258 '((t (:inherit nxml-delimiter)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
259 "Face used for the colon in attribute names."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
260 :group 'nxml-faces)
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
261
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
262 (defface nxml-attribute-local-name
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
263 '((t (:inherit font-lock-variable-name-face)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
264 "Face used for the local name of attributes."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
265 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
266
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
267 (defface nxml-namespace-attribute-xmlns
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
268 '((t (:inherit nxml-attribute-prefix)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
269 "Face used for `xmlns' in namespace attributes."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
270 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
271
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
272 (defface nxml-namespace-attribute-colon
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
273 '((t (:inherit nxml-attribute-colon)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
274 "Face used for the colon in namespace attributes."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
275 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
276
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
277 (defface nxml-namespace-attribute-prefix
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
278 '((t (:inherit nxml-attribute-local-name)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
279 "Face used for the prefix declared in namespace attributes."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
280 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
281
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
282 (defface nxml-attribute-value
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
283 '((t (:inherit font-lock-string-face)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
284 "Face used for the value of attributes."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
285 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
286
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
287 (defface nxml-attribute-value-delimiter
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
288 '((t (:inherit nxml-attribute-value)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
289 "Face used for the delimiters of attribute values."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
290 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
291
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
292 (defface nxml-namespace-attribute-value
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
293 '((t (:inherit nxml-attribute-value)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
294 "Face used for the value of namespace attributes."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
295 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
296
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
297 (defface nxml-namespace-attribute-value-delimiter
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
298 '((t (:inherit nxml-attribute-value-delimiter)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
299 "Face used for the delimiters of namespace attribute values."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
300 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
301
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
302 (defface nxml-prolog-literal-delimiter
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
303 '((t (:inherit nxml-delimited-data)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
304 "Face used for the delimiters of literals in the prolog."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
305 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
306
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
307 (defface nxml-prolog-literal-content
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
308 '((t (:inherit nxml-delimited-data)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
309 "Face used for the content of literals in the prolog."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
310 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
311
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
312 (defface nxml-prolog-keyword
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
313 '((t (:inherit font-lock-keyword-face)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
314 "Face used for keywords in the prolog."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
315 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
316
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
317 (defface nxml-markup-declaration-delimiter
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
318 '((t (:inherit nxml-delimiter)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
319 "Face used for the delimiters of markup declarations in the prolog.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
320 The delimiters are <! and >."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
321 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
322
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
323 (defface nxml-hash
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
324 '((t (:inherit nxml-name)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
325 "Face used for # before a name in the prolog."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
326 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
327
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
328 (defface nxml-glyph
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
329 '((((type x))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
330 (:family
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
331 "misc-fixed"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
332 :background
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
333 "light grey"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
334 :foreground
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
335 "black"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
336 :weight
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
337 normal
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
338 :slant
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
339 normal))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
340 (t
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
341 (:background
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
342 "light grey"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
343 :foreground
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
344 "black"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
345 :weight
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
346 normal
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
347 :slant
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
348 normal)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
349 "Face used for glyph for char references."
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
350 :group 'nxml-faces)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
351
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
352 ;;; Global variables
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
353
111782
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
354 (defvar nxml-parent-document nil
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
355 "The parent document for a part of a modular document.
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
356 Use `nxml-parent-document-set' to set it.")
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
357 (make-variable-buffer-local 'nxml-parent-document)
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
358 (put 'nxml-parent-document 'safe-local-variable 'stringp)
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
359
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
360 (defvar nxml-prolog-regions nil
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
361 "List of regions in the prolog to be fontified.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
362 See the function `xmltok-forward-prolog' for more information.")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
363 (make-variable-buffer-local 'nxml-prolog-regions)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
364
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
365 (defvar nxml-last-fontify-end nil
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
366 "Position where fontification last ended.
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
367 It is nil if the buffer changed since the last fontification.")
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
368 (make-variable-buffer-local 'nxml-last-fontify-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
369
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
370 (defvar nxml-degraded nil
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
371 "Non-nil if currently operating in degraded mode.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
372 Degraded mode is enabled when an internal error is encountered in the
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
373 fontification or after-change functions.")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
374 (make-variable-buffer-local 'nxml-degraded)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
375
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
376 (defvar nxml-completion-hook nil
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
377 "Hook run by `nxml-complete'.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
378 This hook is run until success.")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
379
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
380 (defvar nxml-in-mixed-content-hook nil
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
381 "Hook to determine whether point is in mixed content.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
382 The hook is called without arguments. It should return nil if it is
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
383 definitely not mixed; non-nil otherwise. The hook will be run until
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
384 one of the functions returns nil.")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
385
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
386 (defvar nxml-mixed-scan-distance 4000
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
387 "Maximum distance from point to scan when checking for mixed content.")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
388
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
389 (defvar nxml-end-tag-indent-scan-distance 4000
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
390 "Maximum distance from point to scan backwards when indenting end-tag.")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
391
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
392 (defvar nxml-char-ref-extra-display t
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
393 "Non-nil means display extra information for character references.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
394 The extra information consists of a tooltip with the character name
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
395 and, if `nxml-char-ref-display-glyph-flag' is non-nil, a glyph
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
396 corresponding to the referenced character following the character
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
397 reference.")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
398 (make-variable-buffer-local 'nxml-char-ref-extra-display)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
399
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
400 (defvar nxml-mode-map
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
401 (let ((map (make-sparse-keymap)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
402 (define-key map "\M-\C-u" 'nxml-backward-up-element)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
403 (define-key map "\M-\C-d" 'nxml-down-element)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
404 (define-key map "\M-\C-n" 'nxml-forward-element)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
405 (define-key map "\M-\C-p" 'nxml-backward-element)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
406 (define-key map "\M-{" 'nxml-backward-paragraph)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
407 (define-key map "\M-}" 'nxml-forward-paragraph)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
408 (define-key map "\M-h" 'nxml-mark-paragraph)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
409 (define-key map "\C-c\C-f" 'nxml-finish-element)
111128
d38d192ed185 Bind "C-c ]" to block-closing commands in several modes.
Chong Yidong <cyd@stupidchicken.com>
parents: 108987
diff changeset
410 (define-key map "\C-c]" 'nxml-finish-element)
108714
99ad939c8d05 * nxml/nxml-mode.el (nxml-mode-map): Bind C-c / to
Chong Yidong <cyd@stupidchicken.com>
parents: 107378
diff changeset
411 (define-key map "\C-c/" 'nxml-finish-element)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
412 (define-key map "\C-c\C-m" 'nxml-split-element)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
413 (define-key map "\C-c\C-b" 'nxml-balanced-close-start-tag-block)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
414 (define-key map "\C-c\C-i" 'nxml-balanced-close-start-tag-inline)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
415 (define-key map "\C-c\C-x" 'nxml-insert-xml-declaration)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
416 (define-key map "\C-c\C-d" 'nxml-dynamic-markup-word)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
417 ;; u is for Unicode
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
418 (define-key map "\C-c\C-u" 'nxml-insert-named-char)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
419 (define-key map "\C-c\C-o" nxml-outline-prefix-map)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
420 (define-key map [S-mouse-2] 'nxml-mouse-hide-direct-text-content)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
421 (define-key map "/" 'nxml-electric-slash)
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
422 (define-key map [C-return] 'nxml-complete)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
423 (when nxml-bind-meta-tab-to-complete-flag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
424 (define-key map "\M-\t" 'nxml-complete))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
425 map)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
426 "Keymap for nxml-mode.")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
427
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
428 (defvar nxml-font-lock-keywords
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
429 '(nxml-fontify-matcher)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
430 "Default font lock keywords for nxml-mode.")
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
431
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
432 (defsubst nxml-set-face (start end face)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
433 (when (and face (< start end))
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
434 (font-lock-append-text-property start end 'face face)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
435
111782
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
436 (defun nxml-parent-document-set (parent-document)
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
437 "Set `nxml-parent-document' and inherit the DTD &c."
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
438 ;; FIXME: this does not work.
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
439 ;; the idea is that by inheriting some variables from the parent,
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
440 ;; `rng-validate-mode' will validate entities declared in the parent.
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
441 ;; alas, the most interesting variables (`rng-compile-table' et al)
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
442 ;; are circular and cannot be printed even with `print-circle'.
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
443 (interactive "fParent document")
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
444 (let (dtd current-schema current-schema-file-name compile-table
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
445 ipattern-table last-ipattern-index)
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
446 (when (string= (file-truename parent-document)
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
447 (file-truename buffer-file-name))
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
448 (error "Parent document cannot be the same as the document"))
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
449 (with-current-buffer (find-file-noselect parent-document)
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
450 (setq dtd rng-dtd
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
451 current-schema rng-current-schema
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
452 current-schema-file-name rng-current-schema-file-name
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
453 compile-table rng-compile-table
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
454 ipattern-table rng-ipattern-table
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
455 last-ipattern-index rng-last-ipattern-index
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
456 parent-document buffer-file-name))
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
457 (setq rng-dtd dtd
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
458 rng-current-schema current-schema
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
459 rng-current-schema-file-name current-schema-file-name
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
460 rng-compile-table compile-table
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
461 rng-ipattern-table ipattern-table
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
462 rng-last-ipattern-index last-ipattern-index
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
463 nxml-parent-document parent-document)
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
464 (message "Set parent document to %s" parent-document)
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
465 (when rng-validate-mode
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
466 (rng-validate-while-idle (current-buffer)))))
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
467
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
468 ;;;###autoload
111782
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
469 (define-derived-mode nxml-mode text-mode "nXML"
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
470 ;; We use C-c C-i instead of \\[nxml-balanced-close-start-tag-inline]
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
471 ;; because Emacs turns C-c C-i into C-c TAB which is hard to type and
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
472 ;; not mnemonic.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
473 "Major mode for editing XML.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
474
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
475 \\[nxml-finish-element] finishes the current element by inserting an end-tag.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
476 C-c C-i closes a start-tag with `>' and then inserts a balancing end-tag
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
477 leaving point between the start-tag and end-tag.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
478 \\[nxml-balanced-close-start-tag-block] is similar but for block rather than inline elements:
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
479 the start-tag, point, and end-tag are all left on separate lines.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
480 If `nxml-slash-auto-complete-flag' is non-nil, then inserting a `</'
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
481 automatically inserts the rest of the end-tag.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
482
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
483 \\[nxml-complete] performs completion on the symbol preceding point.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
484
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
485 \\[nxml-dynamic-markup-word] uses the contents of the current buffer
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
486 to choose a tag to put around the word preceding point.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
487
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
488 Sections of the document can be displayed in outline form. The
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
489 variable `nxml-section-element-name-regexp' controls when an element
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
490 is recognized as a section. The same key sequences that change
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
491 visibility in outline mode are used except that they start with C-c C-o
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
492 instead of C-c.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
493
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
494 Validation is provided by the related minor-mode `rng-validate-mode'.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
495 This also makes completion schema- and context- sensitive. Element
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
496 names, attribute names, attribute values and namespace URIs can all be
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
497 completed. By default, `rng-validate-mode' is automatically enabled.
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
498 You can toggle it using \\[rng-validate-mode] or change the default by
87712
a9f53375739a (nxml-mode): Call rng-nxml-mode-init directly.
Jason Rumney <jasonr@gnu.org>
parents: 87665
diff changeset
499 customizing `rng-nxml-auto-validate-flag'.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
500
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
501 \\[indent-for-tab-command] indents the current line appropriately.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
502 This can be customized using the variable `nxml-child-indent'
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
503 and the variable `nxml-attribute-indent'.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
504
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
505 \\[nxml-insert-named-char] inserts a character reference using
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
506 the character's name (by default, the Unicode name).
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
507 \\[universal-argument] \\[nxml-insert-named-char] inserts the character directly.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
508
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
509 The Emacs commands that normally operate on balanced expressions will
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
510 operate on XML markup items. Thus \\[forward-sexp] will move forward
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
511 across one markup item; \\[backward-sexp] will move backward across
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
512 one markup item; \\[kill-sexp] will kill the following markup item;
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
513 \\[mark-sexp] will mark the following markup item. By default, each
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
514 tag each treated as a single markup item; to make the complete element
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
515 be treated as a single markup item, set the variable
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
516 `nxml-sexp-element-flag' to t. For more details, see the function
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
517 `nxml-forward-balanced-item'.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
518
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
519 \\[nxml-backward-up-element] and \\[nxml-down-element] move up and down the element structure.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
520
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
521 Many aspects this mode can be customized using
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
522 \\[customize-group] nxml RET."
111782
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
523 ;; (kill-all-local-variables)
87793
b0683497550c (nxml-mode): Use mode-line-process to indicate the use of degraded mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87719
diff changeset
524 (set (make-local-variable 'mode-line-process) '((nxml-degraded "/degraded")))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
525 ;; We'll determine the fill prefix ourselves
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
526 (make-local-variable 'adaptive-fill-mode)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
527 (setq adaptive-fill-mode nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
528 (make-local-variable 'forward-sexp-function)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
529 (setq forward-sexp-function 'nxml-forward-balanced-item)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
530 (make-local-variable 'indent-line-function)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
531 (setq indent-line-function 'nxml-indent-line)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
532 (make-local-variable 'fill-paragraph-function)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
533 (setq fill-paragraph-function 'nxml-do-fill-paragraph)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
534 ;; Comment support
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
535 ;; This doesn't seem to work too well;
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
536 ;; I think we should probably roll our own nxml-comment-dwim function.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
537 (make-local-variable 'comment-indent-function)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
538 (setq comment-indent-function 'nxml-indent-line)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
539 (make-local-variable 'comment-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
540 (setq comment-start "<!--")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
541 (make-local-variable 'comment-start-skip)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
542 (setq comment-start-skip "<!--[ \t\r\n]*")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
543 (make-local-variable 'comment-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
544 (setq comment-end "-->")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
545 (make-local-variable 'comment-end-skip)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
546 (setq comment-end-skip "[ \t\r\n]*-->")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
547 (make-local-variable 'comment-line-break-function)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
548 (setq comment-line-break-function 'nxml-newline-and-indent)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
549 (use-local-map nxml-mode-map)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
550 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
551 (save-restriction
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
552 (widen)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
553 (nxml-clear-dependent-regions (point-min) (point-max))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
554 (setq nxml-scan-end (copy-marker (point-min) nil))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
555 (nxml-with-unmodifying-text-property-changes
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
556 (nxml-clear-inside (point-min) (point-max))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
557 (nxml-with-invisible-motion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
558 (nxml-scan-prolog)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
559 (add-hook 'after-change-functions 'nxml-after-change nil t)
93917
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
560 (add-hook 'change-major-mode-hook 'nxml-cleanup nil t)
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
561
91924
b6c62ca6da76 (nxml-mode): Don't add a write-contents-hook.
Jason Rumney <jasonr@gnu.org>
parents: 87793
diff changeset
562 ;; Emacs 23 handles the encoding attribute on the xml declaration
b6c62ca6da76 (nxml-mode): Don't add a write-contents-hook.
Jason Rumney <jasonr@gnu.org>
parents: 87793
diff changeset
563 ;; transparently to nxml-mode, so there is no longer a need for the below
b6c62ca6da76 (nxml-mode): Don't add a write-contents-hook.
Jason Rumney <jasonr@gnu.org>
parents: 87793
diff changeset
564 ;; hook. The hook also had the drawback of overriding explicit user
b6c62ca6da76 (nxml-mode): Don't add a write-contents-hook.
Jason Rumney <jasonr@gnu.org>
parents: 87793
diff changeset
565 ;; instruction to save as some encoding other than utf-8.
b6c62ca6da76 (nxml-mode): Don't add a write-contents-hook.
Jason Rumney <jasonr@gnu.org>
parents: 87793
diff changeset
566 ;;; (add-hook 'write-contents-hooks 'nxml-prepare-to-save)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
567 (when (not (and (buffer-file-name) (file-exists-p (buffer-file-name))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
568 (when (and nxml-default-buffer-file-coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
569 (not (local-variable-p 'buffer-file-coding-system)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
570 (setq buffer-file-coding-system nxml-default-buffer-file-coding-system))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
571 (when nxml-auto-insert-xml-declaration-flag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
572 (nxml-insert-xml-declaration)))
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
573
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
574 (setq font-lock-defaults
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
575 '(nxml-font-lock-keywords
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
576 t ; keywords-only; we highlight comments and strings here
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
577 nil ; font-lock-keywords-case-fold-search. XML is case sensitive
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
578 nil ; no special syntax table
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
579 nil ; no automatic syntactic fontification
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
580 (font-lock-extend-after-change-region-function
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
581 . nxml-extend-after-change-region)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
582 (font-lock-extend-region-functions . (nxml-extend-region))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
583 (jit-lock-contextually . t)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
584 (font-lock-unfontify-region-function . nxml-unfontify-region)))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
585
87712
a9f53375739a (nxml-mode): Call rng-nxml-mode-init directly.
Jason Rumney <jasonr@gnu.org>
parents: 87665
diff changeset
586 (rng-nxml-mode-init)
111782
49c747159b30 * lisp/nxml/nxml-mode.el (nxml-parent-document): Add a variable.
Sam Steingold <sds@gnu.org>
parents: 111128
diff changeset
587 (nxml-enable-unicode-char-name-sets))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
588
93917
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
589 (defun nxml-cleanup ()
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
590 "Clean up after nxml-mode."
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
591 ;; Disable associated minor modes.
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
592 (rng-validate-mode -1)
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
593 ;; Clean up fontification.
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
594 (save-excursion
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
595 (widen)
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
596 (let ((inhibit-read-only t)
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
597 (buffer-undo-list t)
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
598 (modified (buffer-modified-p)))
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
599 (nxml-with-invisible-motion
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
600 (remove-text-properties (point-min) (point-max) '(face)))
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
601 (set-buffer-modified-p modified)))
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
602 (remove-hook 'change-major-mode-hook 'nxml-cleanup t))
3fad91a9740c 2008-04-09 Lennart Borgman <lennart.borgman@gmail.com>
Jason Rumney <jasonr@gnu.org>
parents: 91924
diff changeset
603
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
604 (defun nxml-degrade (context err)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
605 (message "Internal nXML mode error in %s (%s), degrading"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
606 context
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
607 (error-message-string err))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
608 (ding)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
609 (setq nxml-degraded t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
610 (setq nxml-prolog-end 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
611 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
612 (save-restriction
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
613 (widen)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
614 (nxml-with-unmodifying-text-property-changes
87793
b0683497550c (nxml-mode): Use mode-line-process to indicate the use of degraded mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87719
diff changeset
615 (nxml-clear-inside (point-min) (point-max))))))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
616
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
617 ;;; Change management
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
618
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
619 (defun nxml-debug-region (start end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
620 (interactive "r")
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
621 (let ((font-lock-beg start)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
622 (font-lock-end end))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
623 (nxml-extend-region)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
624 (goto-char font-lock-beg)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
625 (set-mark font-lock-end)))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
626
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
627 (defun nxml-after-change (start end pre-change-length)
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
628 ; In font-lock mode, nxml-after-change1 is called via
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
629 ; nxml-extend-after-change-region instead so that the updated
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
630 ; book-keeping information is available for fontification.
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
631 (unless (or font-lock-mode nxml-degraded)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
632 (nxml-with-degradation-on-error 'nxml-after-change
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
633 (save-excursion
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
634 (save-restriction
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
635 (widen)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
636 (save-match-data
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
637 (nxml-with-invisible-motion
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
638 (nxml-with-unmodifying-text-property-changes
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
639 (nxml-after-change1
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
640 start end pre-change-length)))))))))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
641
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
642 (defun nxml-after-change1 (start end pre-change-length)
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
643 "After-change bookkeeping.
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
644 Returns a cons cell containing a possibly-enlarged change region.
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
645 You must call `nxml-extend-region' on this expanded region to obtain
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
646 the full extent of the area needing refontification.
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
647
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
648 For bookkeeping, call this function even when fontification is
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
649 disabled."
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
650 (let ((pre-change-end (+ start pre-change-length)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
651 (setq start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
652 (nxml-adjust-start-for-dependent-regions start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
653 end
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
654 pre-change-length))
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
655 ;; If the prolog might have changed, rescan the prolog
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
656 (when (<= start
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
657 ;; Add 2 so as to include the < and following char that
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
658 ;; start the instance (document element), since changing
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
659 ;; these can change where the prolog ends.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
660 (+ nxml-prolog-end 2))
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
661 ;; end must be extended to at least the end of the old prolog in
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
662 ;; case the new prolog is shorter
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
663 (when (< pre-change-end nxml-prolog-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
664 (setq end
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
665 ;; don't let end get out of range even if pre-change-length
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
666 ;; is bogus
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
667 (min (point-max)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
668 (+ end (- nxml-prolog-end pre-change-end)))))
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
669 (nxml-scan-prolog)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
670 (setq start (point-min))))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
671
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
672 (when (> end nxml-prolog-end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
673 (goto-char start)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
674 (nxml-move-tag-backwards (point-min))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
675 (setq start (point))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
676 (setq end (max (nxml-scan-after-change start end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
677 end)))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
678
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
679 (nxml-debug-change "nxml-after-change1" start end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
680 (cons start end))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
681
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
682 ;;; Encodings
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
683
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
684 (defun nxml-insert-xml-declaration ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
685 "Insert an XML declaration at the beginning of buffer.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
686 The XML declaration will declare an encoding depending on the buffer's
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
687 `buffer-file-coding-system'."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
688 (interactive "*")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
689 (let ((coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
690 (if (and buffer-file-coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
691 (coding-system-p buffer-file-coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
692 (coding-system-get buffer-file-coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
693 'mime-charset))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
694 buffer-file-coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
695 (nxml-choose-utf-coding-system))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
696 (goto-char (point-min))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
697 (insert (format "<?xml version=\"1.0\" encoding=\"%s\"?>\n"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
698 (nxml-coding-system-name coding-system)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
699
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
700 (defun nxml-prepare-to-save ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
701 (unless (and (not enable-multibyte-characters)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
702 (local-variable-p 'buffer-file-coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
703 buffer-file-coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
704 (or (eq (coding-system-type buffer-file-coding-system) 5)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
705 (eq buffer-file-coding-system 'no-conversion)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
706 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
707 (setq buffer-file-coding-system (nxml-select-coding-system))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
708 ;; nil from a function in `write-contents-hooks' means
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
709 ;; to continue and write the file as normal
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
710 nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
711
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
712 (defun nxml-select-coding-system ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
713 (let* ((suitable-coding-systems
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
714 (find-coding-systems-region (point-min) (point-max)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
715 (enc-pos (progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
716 (goto-char (point-min))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
717 (xmltok-get-declared-encoding-position)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
718 (enc-name
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
719 (and (consp enc-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
720 (buffer-substring-no-properties (car enc-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
721 (cdr enc-pos))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
722 (coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
723 (cond (enc-name
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
724 (if (string= (downcase enc-name) "utf-16")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
725 (nxml-choose-utf-16-coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
726 (nxml-mime-charset-coding-system enc-name)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
727 (enc-pos (nxml-choose-utf-coding-system)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
728 ;; Make sure we have a coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
729 (unless coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
730 (setq coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
731 (and (not buffer-read-only)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
732 (nxml-choose-suitable-coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
733 suitable-coding-systems)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
734 (let ((message
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
735 (if enc-name
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
736 (format "Unknown encoding %s" enc-name)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
737 "XML declaration is not well-formed")))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
738 (cond ((not coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
739 (error "%s" message))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
740 ((y-or-n-p
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
741 (concat message
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
742 ". "
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
743 (format (if enc-name
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
744 "Save with %s"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
745 "Modify and save with encoding %s")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
746 (nxml-coding-system-name coding-system))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
747 " "))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
748 (nxml-fix-encoding-declaration enc-pos coding-system))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
749 (t (signal 'quit nil)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
750 ;; Make sure it can encode all the characters in the buffer
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
751 (unless (or (memq (coding-system-base coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
752 suitable-coding-systems)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
753 (equal suitable-coding-systems '(undecided)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
754 (let ((message
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
755 (nxml-unsuitable-coding-system-message coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
756 enc-name)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
757 (setq coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
758 (and (not buffer-read-only)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
759 (nxml-choose-suitable-coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
760 suitable-coding-systems)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
761 (cond ((not coding-system) (error "%s" message))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
762 ((y-or-n-p (concat message
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
763 (format ". Save with %s "
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
764 (nxml-coding-system-name
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
765 coding-system))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
766 (nxml-fix-encoding-declaration enc-pos coding-system))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
767 (t (signal 'quit nil)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
768 ;; Merge the newline type of our existing encoding
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
769 (let ((current-eol-type
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
770 (coding-system-eol-type buffer-file-coding-system)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
771 (when (and current-eol-type (integerp current-eol-type))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
772 (setq coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
773 (coding-system-change-eol-conversion coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
774 current-eol-type))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
775 coding-system))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
776
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
777 (defun nxml-unsuitable-coding-system-message (coding-system &optional enc-name)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
778 (if (nxml-coding-system-unicode-p coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
779 "Cannot translate some characters to Unicode"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
780 (format "Cannot encode some characters with %s"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
781 (or enc-name
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
782 (nxml-coding-system-name coding-system)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
783
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
784 (defconst nxml-utf-16-coding-systems (and (coding-system-p 'utf-16-be)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
785 (coding-system-p 'utf-16-le)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
786 '(utf-16-be utf-16-le)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
787
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
788 (defconst nxml-utf-coding-systems (cons 'utf-8 nxml-utf-16-coding-systems))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
789
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
790 (defun nxml-coding-system-unicode-p (coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
791 (nxml-coding-system-member (coding-system-base coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
792 nxml-utf-coding-systems))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
793
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
794 (defun nxml-coding-system-name (coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
795 (setq coding-system (coding-system-base coding-system))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
796 (symbol-name
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
797 (if (nxml-coding-system-member coding-system nxml-utf-16-coding-systems)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
798 'utf-16
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
799 (or (coding-system-get coding-system 'mime-charset)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
800 coding-system))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
801
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
802 (defun nxml-fix-encoding-declaration (enc-pos coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
803 (let ((charset (nxml-coding-system-name coding-system)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
804 (cond ((consp enc-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
805 (delete-region (car enc-pos) (cdr enc-pos))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
806 (goto-char (car enc-pos))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
807 (insert charset))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
808 ((integerp enc-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
809 (goto-char enc-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
810 (insert " encoding=\"" charset ?\"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
811 (t
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
812 (goto-char (point-min))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
813 (insert "<?xml version=\"1.0\" encoding=\""
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
814 charset
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
815 "\"?>\n")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
816 (when (and (not enc-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
817 (let ((case-fold-search t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
818 (looking-at xmltok-bad-xml-decl-regexp)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
819 (delete-region (point) (match-end 0)))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
820
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
821 (defun nxml-choose-suitable-coding-system (suitable-coding-systems)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
822 (let (ret coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
823 (if (and buffer-file-coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
824 (memq (coding-system-base buffer-file-coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
825 suitable-coding-systems))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
826 buffer-file-coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
827 (while (and suitable-coding-systems (not ret))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
828 (setq coding-system (car suitable-coding-systems))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
829 (if (coding-system-get coding-system 'mime-charset)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
830 (setq ret coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
831 (setq suitable-coding-systems (cdr suitable-coding-systems))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
832 ret)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
833
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
834 (defun nxml-choose-utf-coding-system ()
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
835 (let ((cur (and (local-variable-p 'buffer-file-coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
836 buffer-file-coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
837 (coding-system-base buffer-file-coding-system))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
838 (cond ((car (nxml-coding-system-member cur nxml-utf-coding-systems)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
839 ((and nxml-prefer-utf-16-to-utf-8-flag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
840 (coding-system-p 'utf-16-le)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
841 (coding-system-p 'utf-16-be))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
842 (if nxml-prefer-utf-16-little-to-big-endian-flag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
843 'utf-16-le
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
844 'utf-16-be))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
845 (t 'utf-8))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
846
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
847 (defun nxml-choose-utf-16-coding-system ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
848 (let ((cur (and (local-variable-p 'buffer-file-coding-system)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
849 buffer-file-coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
850 (coding-system-base buffer-file-coding-system))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
851 (cond ((car (nxml-coding-system-member cur nxml-utf-16-coding-systems)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
852 (nxml-prefer-utf-16-little-to-big-endian-flag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
853 (and (coding-system-p 'utf-16-le) 'utf-16-le))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
854 (t (and (coding-system-p 'utf-16-be) 'utf-16-be)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
855
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
856 (defun nxml-coding-system-member (coding-system coding-systems)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
857 (let (ret)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
858 (while (and coding-systems (not ret))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
859 (if (coding-system-equal coding-system
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
860 (car coding-systems))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
861 (setq ret coding-systems)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
862 (setq coding-systems (cdr coding-systems))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
863 ret))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
864
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
865 ;;; Fontification
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
866
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
867 (defun nxml-unfontify-region (start end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
868 (font-lock-default-unfontify-region start end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
869 (nxml-clear-char-ref-extra-display start end))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
870
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
871 (defvar font-lock-beg) (defvar font-lock-end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
872 (defun nxml-extend-region ()
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
873 "Extend the region to hold the minimum area we can fontify with nXML.
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
874 Called with `font-lock-beg' and `font-lock-end' dynamically bound."
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
875 (let ((start font-lock-beg)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
876 (end font-lock-end))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
877
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
878 (nxml-debug-change "nxml-extend-region(input)" start end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
879
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
880 (when (< start nxml-prolog-end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
881 (setq start (point-min)))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
882
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
883 (cond ((<= end nxml-prolog-end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
884 (setq end nxml-prolog-end))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
885
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
886 (t
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
887 (goto-char start)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
888 ;; some font-lock backends (like Emacs 22 jit-lock) snap
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
889 ;; the region to the beginning of the line no matter what
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
890 ;; we say here. To mitigate the resulting excess
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
891 ;; fontification, ignore leading whitespace.
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
892 (skip-syntax-forward " ")
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
893
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
894 ;; find the beginning of the previous tag
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
895 (when (not (equal (char-after) ?\<))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
896 (search-backward "<" nxml-prolog-end t))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
897 (nxml-ensure-scan-up-to-date)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
898 (nxml-move-outside-backwards)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
899 (setq start (point))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
900
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
901 (while (< (point) end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
902 (nxml-tokenize-forward))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
903
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
904 (setq end (point))))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
905
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
906 (when (or (< start font-lock-beg)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
907 (> end font-lock-end))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
908 (setq font-lock-beg start
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
909 font-lock-end end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
910 (nxml-debug-change "nxml-extend-region" start end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
911 t)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
912
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
913 (defun nxml-extend-after-change-region (start end pre-change-length)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
914 (unless nxml-degraded
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
915 (setq nxml-last-fontify-end nil)
106873
8357132d4077 Fix return value of nxml-extend-after-change-region.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
916 (let ((region (nxml-with-degradation-on-error
8357132d4077 Fix return value of nxml-extend-after-change-region.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
917 'nxml-extend-after-change-region
8357132d4077 Fix return value of nxml-extend-after-change-region.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
918 (save-excursion
8357132d4077 Fix return value of nxml-extend-after-change-region.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
919 (save-restriction
8357132d4077 Fix return value of nxml-extend-after-change-region.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
920 (widen)
8357132d4077 Fix return value of nxml-extend-after-change-region.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
921 (save-match-data
8357132d4077 Fix return value of nxml-extend-after-change-region.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
922 (nxml-with-invisible-motion
8357132d4077 Fix return value of nxml-extend-after-change-region.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
923 (nxml-with-unmodifying-text-property-changes
8357132d4077 Fix return value of nxml-extend-after-change-region.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
924 (nxml-extend-after-change-region1
8357132d4077 Fix return value of nxml-extend-after-change-region.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
925 start end pre-change-length)))))))))
8357132d4077 Fix return value of nxml-extend-after-change-region.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
926 (if (consp region) region))))
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
927
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
928 (defun nxml-extend-after-change-region1 (start end pre-change-length)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
929 (let* ((region (nxml-after-change1 start end pre-change-length))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
930 (font-lock-beg (car region))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
931 (font-lock-end (cdr region)))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
932
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
933 (nxml-extend-region)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
934 (cons font-lock-beg font-lock-end)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
935
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
936 (defun nxml-fontify-matcher (bound)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
937 "Called as font-lock keyword matcher."
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
938
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
939 (unless nxml-degraded
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
940 (nxml-debug-change "nxml-fontify-matcher" (point) bound)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
941
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
942 (when (< (point) nxml-prolog-end)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
943 ;; prolog needs to be fontified in one go, and
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
944 ;; nxml-extend-region makes sure we start at BOB.
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
945 (assert (bobp))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
946 (nxml-fontify-prolog)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
947 (goto-char nxml-prolog-end))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
948
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
949 (let (xmltok-dependent-regions
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
950 xmltok-errors)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
951 (while (and (nxml-tokenize-forward)
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
952 (<= (point) bound)) ; intervals are open-ended
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
953 (nxml-apply-fontify-rule)))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
954
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
955 (setq nxml-last-fontify-end (point)))
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
956
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
957 ;; Since we did the fontification internally, tell font-lock to not
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
958 ;; do anything itself.
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
959 nil)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
960
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
961 (defun nxml-fontify-prolog ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
962 "Fontify the prolog.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
963 The buffer is assumed to be prepared for fontification.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
964 This does not set the fontified property, but it does clear
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
965 faces appropriately."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
966 (let ((regions nxml-prolog-regions))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
967 (while regions
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
968 (let ((region (car regions)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
969 (nxml-apply-fontify-rule (aref region 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
970 (aref region 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
971 (aref region 2)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
972 (setq regions (cdr regions)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
973
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
974 ;; Vectors identify a substring of the token to be highlighted in some face.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
975
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
976 ;; Token types returned by xmltok-forward.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
977
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
978 (put 'start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
979 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
980 '([nil 1 nxml-tag-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
981 [-1 nil nxml-tag-delimiter]
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
982 (element-qname . 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
983 attributes))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
984
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
985 (put 'partial-start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
986 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
987 '([nil 1 nxml-tag-delimiter]
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
988 (element-qname . 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
989 attributes))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
990
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
991 (put 'end-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
992 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
993 '([nil 1 nxml-tag-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
994 [1 2 nxml-tag-slash]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
995 [-1 nil nxml-tag-delimiter]
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
996 (element-qname . 2)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
997
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
998 (put 'partial-end-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
999 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1000 '([nil 1 nxml-tag-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1001 [1 2 nxml-tag-slash]
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1002 (element-qname . 2)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1003
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1004 (put 'empty-element
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1005 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1006 '([nil 1 nxml-tag-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1007 [-2 -1 nxml-tag-slash]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1008 [-1 nil nxml-tag-delimiter]
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1009 (element-qname . 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1010 attributes))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1011
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1012 (put 'partial-empty-element
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1013 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1014 '([nil 1 nxml-tag-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1015 [-1 nil nxml-tag-slash]
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1016 (element-qname . 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1017 attributes))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1018
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1019 (put 'char-ref
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1020 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1021 '([nil 2 nxml-char-ref-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1022 [2 -1 nxml-char-ref-number]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1023 [-1 nil nxml-char-ref-delimiter]
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1024 char-ref))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1025
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1026 (put 'entity-ref
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1027 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1028 '([nil 1 nxml-entity-ref-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1029 [1 -1 nxml-entity-ref-name]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1030 [-1 nil nxml-entity-ref-delimiter]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1031
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1032 (put 'comment
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1033 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1034 '([nil 4 nxml-comment-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1035 [4 -3 nxml-comment-content]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1036 [-3 nil nxml-comment-delimiter]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1037
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1038 (put 'processing-instruction
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1039 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1040 '([nil 2 nxml-processing-instruction-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1041 [-2 nil nxml-processing-instruction-delimiter]
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1042 processing-instruction-content))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1043
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1044 (put 'cdata-section
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1045 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1046 '([nil 3 nxml-cdata-section-delimiter] ; <![
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1047 [3 8 nxml-cdata-section-CDATA] ; CDATA
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1048 [8 9 nxml-cdata-section-delimiter] ; [
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1049 [9 -3 nxml-cdata-section-content] ; ]]>
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1050 [-3 nil nxml-cdata-section-delimiter]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1051
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1052 (put 'data
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1053 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1054 '([nil nil nxml-text]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1055
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1056 ;; Prolog region types in list returned by xmltok-forward-prolog.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1057
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1058 (put 'xml-declaration
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1059 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1060 '([nil 2 nxml-processing-instruction-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1061 [2 5 nxml-processing-instruction-target]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1062 [-2 nil nxml-processing-instruction-delimiter]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1063
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1064 (put 'xml-declaration-attribute-name
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1065 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1066 '([nil nil nxml-attribute-local-name]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1067
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1068 (put 'xml-declaration-attribute-value
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1069 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1070 '([nil 1 nxml-attribute-value-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1071 [1 -1 nxml-attribute-value]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1072 [-1 nil nxml-attribute-value-delimiter]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1073
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1074 (put 'processing-instruction-left
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1075 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1076 '([nil 2 nxml-processing-instruction-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1077 [2 nil nxml-processing-instruction-target]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1078
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1079 (put 'processing-instruction-right
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1080 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1081 '([nil -2 nxml-processing-instruction-content]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1082 [-2 nil nxml-processing-instruction-delimiter]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1083
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1084 (put 'literal
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1085 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1086 '([nil 1 nxml-prolog-literal-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1087 [1 -1 nxml-prolog-literal-content]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1088 [-1 nil nxml-prolog-literal-delimiter]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1089
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1090 (put 'keyword
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1091 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1092 '([nil nil nxml-prolog-keyword]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1093
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1094 (put 'markup-declaration-open
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1095 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1096 '([0 2 nxml-markup-declaration-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1097 [2 nil nxml-prolog-keyword]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1098
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1099 (put 'markup-declaration-close
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1100 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1101 '([nil nil nxml-markup-declaration-delimiter]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1102
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1103 (put 'internal-subset-open
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1104 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1105 '([nil nil nxml-markup-declaration-delimiter]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1106
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1107 (put 'internal-subset-close
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1108 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1109 '([nil 1 nxml-markup-declaration-delimiter]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1110 [-1 nil nxml-markup-declaration-delimiter]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1111
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1112 (put 'hash-name
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1113 'nxml-fontify-rule
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1114 '([nil 1 nxml-hash]
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1115 [1 nil nxml-prolog-keyword]))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1116
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1117 (defun nxml-apply-fontify-rule (&optional type start end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1118 (let ((rule (get (or type xmltok-type) 'nxml-fontify-rule)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1119 (unless start (setq start xmltok-start))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1120 (unless end (setq end (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1121 (while rule
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1122 (let* ((action (car rule)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1123 (setq rule (cdr rule))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1124 (cond ((vectorp action)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1125 (nxml-set-face (let ((offset (aref action 0)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1126 (cond ((not offset) start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1127 ((< offset 0) (+ end offset))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1128 (t (+ start offset))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1129 (let ((offset (aref action 1)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1130 (cond ((not offset) end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1131 ((< offset 0) (+ end offset))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1132 (t (+ start offset))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1133 (aref action 2)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1134 ((and (consp action)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1135 (eq (car action) 'element-qname))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1136 (when xmltok-name-end ; maybe nil in partial-end-tag case
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1137 (nxml-fontify-qname (+ start (cdr action))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1138 xmltok-name-colon
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1139 xmltok-name-end
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1140 'nxml-element-prefix
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1141 'nxml-element-colon
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1142 'nxml-element-local-name)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1143 ((eq action 'attributes)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1144 (nxml-fontify-attributes))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1145 ((eq action 'processing-instruction-content)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1146 (nxml-set-face (+ start 2)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1147 xmltok-name-end
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1148 'nxml-processing-instruction-target)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1149 (nxml-set-face (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1150 (goto-char xmltok-name-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1151 (skip-chars-forward " \t\r\n")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1152 (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1153 (- end 2)
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1154 'nxml-processing-instruction-content))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1155 ((eq action 'char-ref)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1156 (nxml-char-ref-display-extra start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1157 end
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1158 (xmltok-char-number start end)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1159 (t (error "Invalid nxml-fontify-rule action %s" action)))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1160
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1161 (defun nxml-fontify-attributes ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1162 (while xmltok-namespace-attributes
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1163 (nxml-fontify-attribute (car xmltok-namespace-attributes)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1164 'namespace)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1165 (setq xmltok-namespace-attributes
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1166 (cdr xmltok-namespace-attributes)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1167 (while xmltok-attributes
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1168 (nxml-fontify-attribute (car xmltok-attributes))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1169 (setq xmltok-attributes
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1170 (cdr xmltok-attributes))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1171
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1172 (defun nxml-fontify-attribute (att &optional namespace-declaration)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1173 (if namespace-declaration
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1174 (nxml-fontify-qname (xmltok-attribute-name-start att)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1175 (xmltok-attribute-name-colon att)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1176 (xmltok-attribute-name-end att)
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1177 'nxml-namespace-attribute-xmlns
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1178 'nxml-namespace-attribute-colon
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1179 'nxml-namespace-attribute-prefix
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1180 'nxml-namespace-attribute-xmlns)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1181 (nxml-fontify-qname (xmltok-attribute-name-start att)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1182 (xmltok-attribute-name-colon att)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1183 (xmltok-attribute-name-end att)
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1184 'nxml-attribute-prefix
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1185 'nxml-attribute-colon
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1186 'nxml-attribute-local-name))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1187 (let ((start (xmltok-attribute-value-start att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1188 (end (xmltok-attribute-value-end att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1189 (refs (xmltok-attribute-refs att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1190 (delimiter-face (if namespace-declaration
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1191 'nxml-namespace-attribute-value-delimiter
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1192 'nxml-attribute-value-delimiter))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1193 (value-face (if namespace-declaration
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1194 'nxml-namespace-attribute-value
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
1195 'nxml-attribute-value)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1196 (when start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1197 (nxml-set-face (1- start) start delimiter-face)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1198 (nxml-set-face end (1+ end) delimiter-face)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1199 (while refs
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1200 (let* ((ref (car refs))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1201 (ref-type (aref ref 0))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1202 (ref-start (aref ref 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1203 (ref-end (aref ref 2)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1204 (nxml-set-face start ref-start value-face)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1205 (nxml-apply-fontify-rule ref-type ref-start ref-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1206 (setq start ref-end))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1207 (setq refs (cdr refs)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1208 (nxml-set-face start end value-face))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1209
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1210 (defun nxml-fontify-qname (start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1211 colon
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1212 end
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1213 prefix-face
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1214 colon-face
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1215 local-name-face
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1216 &optional
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1217 unprefixed-face)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1218 (cond (colon (nxml-set-face start colon prefix-face)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1219 (nxml-set-face colon (1+ colon) colon-face)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1220 (nxml-set-face (1+ colon) end local-name-face))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1221 (t (nxml-set-face start end (or unprefixed-face
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1222 local-name-face)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1223
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1224 ;;; Editing
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1225
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1226 (defun nxml-electric-slash (arg)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1227 "Insert a slash.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1228
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1229 With a prefix ARG, do nothing other than insert the slash.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1230
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1231 Otherwise, if `nxml-slash-auto-complete-flag' is non-nil, insert the
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1232 rest of the end-tag or empty-element if the slash is potentially part
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1233 of an end-tag or the close of an empty-element.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1234
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1235 If the slash is part of an end-tag that is the first non-whitespace
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1236 on the line, reindent the line."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1237 (interactive "*P")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1238 (nxml-ensure-scan-up-to-date)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1239 (let* ((slash-pos (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1240 (end-tag-p (and (eq (char-before slash-pos) ?<)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1241 (not (nxml-get-inside slash-pos))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1242 (at-indentation (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1243 (back-to-indentation)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1244 (eq (point) (1- slash-pos)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1245 (self-insert-command (prefix-numeric-value arg))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1246 (unless arg
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1247 (if nxml-slash-auto-complete-flag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1248 (if end-tag-p
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1249 (condition-case err
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1250 (let ((start-tag-end
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1251 (nxml-scan-element-backward (1- slash-pos) t)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1252 (when start-tag-end
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1253 (insert (xmltok-start-tag-qname) ">")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1254 ;; copy the indentation of the start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1255 (when (and at-indentation
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1256 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1257 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1258 (back-to-indentation)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1259 (eq (point) xmltok-start)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1260 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1261 (indent-line-to (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1262 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1263 (current-column)))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1264 (nxml-scan-error nil))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1265 (when (and (eq (nxml-token-before) (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1266 (eq xmltok-type 'partial-empty-element))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1267 (insert ">")))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1268 (when (and end-tag-p at-indentation)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1269 (nxml-indent-line))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1270
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1271 (defun nxml-balanced-close-start-tag-block ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1272 "Close the start-tag before point with `>' and insert a balancing end-tag.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1273 Point is left between the start-tag and the end-tag.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1274 If there is nothing but whitespace before the `<' that opens the
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1275 start-tag, then put point on a blank line, and put the end-tag on
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1276 another line aligned with the start-tag."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1277 (interactive "*")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1278 (nxml-balanced-close-start-tag 'block))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1279
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1280 (defun nxml-balanced-close-start-tag-inline ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1281 "Close the start-tag before point with `>' and insert a balancing end-tag.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1282 Point is left between the start-tag and the end-tag.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1283 No extra whitespace is inserted."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1284 (interactive "*")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1285 (nxml-balanced-close-start-tag 'inline))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1286
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1287 (defun nxml-balanced-close-start-tag (block-or-inline)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1288 (let ((token-end (nxml-token-before))
105755
cc6727b235b0 * nxml/nxml-mode.el (nxml-balanced-close-start-tag): Use the value
Chong Yidong <cyd@stupidchicken.com>
parents: 105187
diff changeset
1289 (pos (1+ (point)))
cc6727b235b0 * nxml/nxml-mode.el (nxml-balanced-close-start-tag): Use the value
Chong Yidong <cyd@stupidchicken.com>
parents: 105187
diff changeset
1290 (token-start xmltok-start))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1291 (unless (or (eq xmltok-type 'partial-start-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1292 (and (memq xmltok-type '(start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1293 empty-element
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1294 partial-empty-element))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1295 (>= token-end pos)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1296 (error "Not in a start-tag"))
105755
cc6727b235b0 * nxml/nxml-mode.el (nxml-balanced-close-start-tag): Use the value
Chong Yidong <cyd@stupidchicken.com>
parents: 105187
diff changeset
1297 ;; Note that this insertion changes xmltok-start.
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1298 (insert "></"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1299 (buffer-substring-no-properties (+ xmltok-start 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1300 (min xmltok-name-end (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1301 ">")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1302 (if (eq block-or-inline 'inline)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1303 (goto-char pos)
105755
cc6727b235b0 * nxml/nxml-mode.el (nxml-balanced-close-start-tag): Use the value
Chong Yidong <cyd@stupidchicken.com>
parents: 105187
diff changeset
1304 (goto-char token-start)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1305 (back-to-indentation)
105755
cc6727b235b0 * nxml/nxml-mode.el (nxml-balanced-close-start-tag): Use the value
Chong Yidong <cyd@stupidchicken.com>
parents: 105187
diff changeset
1306 (if (= (point) token-start)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1307 (let ((indent (current-column)))
105755
cc6727b235b0 * nxml/nxml-mode.el (nxml-balanced-close-start-tag): Use the value
Chong Yidong <cyd@stupidchicken.com>
parents: 105187
diff changeset
1308 (goto-char pos)
cc6727b235b0 * nxml/nxml-mode.el (nxml-balanced-close-start-tag): Use the value
Chong Yidong <cyd@stupidchicken.com>
parents: 105187
diff changeset
1309 (insert "\n")
cc6727b235b0 * nxml/nxml-mode.el (nxml-balanced-close-start-tag): Use the value
Chong Yidong <cyd@stupidchicken.com>
parents: 105187
diff changeset
1310 (indent-line-to indent)
cc6727b235b0 * nxml/nxml-mode.el (nxml-balanced-close-start-tag): Use the value
Chong Yidong <cyd@stupidchicken.com>
parents: 105187
diff changeset
1311 (goto-char pos)
cc6727b235b0 * nxml/nxml-mode.el (nxml-balanced-close-start-tag): Use the value
Chong Yidong <cyd@stupidchicken.com>
parents: 105187
diff changeset
1312 (insert "\n")
cc6727b235b0 * nxml/nxml-mode.el (nxml-balanced-close-start-tag): Use the value
Chong Yidong <cyd@stupidchicken.com>
parents: 105187
diff changeset
1313 (indent-line-to (+ nxml-child-indent indent)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1314 (goto-char pos)))))
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
1315
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1316 (defun nxml-finish-element ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1317 "Finish the current element by inserting an end-tag."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1318 (interactive "*")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1319 (nxml-finish-element-1 nil))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1320
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1321 (defvar nxml-last-split-position nil
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1322 "Position where `nxml-split-element' split the current element.")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1323
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1324 (defun nxml-split-element ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1325 "Split the current element by inserting an end-tag and a start-tag.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1326 Point is left after the newly inserted start-tag. When repeated,
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1327 split immediately before the previously inserted start-tag and leave
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1328 point unchanged."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1329 (interactive "*")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1330 (setq nxml-last-split-position
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1331 (if (and (eq last-command this-command)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1332 nxml-last-split-position)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1333 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1334 (goto-char nxml-last-split-position)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1335 (nxml-finish-element-1 t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1336 (nxml-finish-element-1 t))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1337
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1338 (defun nxml-finish-element-1 (startp)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1339 "Insert an end-tag for the current element and optionally a start-tag.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1340 The start-tag is inserted if STARTP is non-nil. Return the position
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1341 of the inserted start-tag or nil if none was inserted."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1342 (interactive "*")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1343 (let* ((token-end (nxml-token-before))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1344 (start-tag-end
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1345 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1346 (when (and (< (point) token-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1347 (memq xmltok-type
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1348 '(cdata-section
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1349 processing-instruction
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1350 comment
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1351 start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1352 end-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1353 empty-element)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1354 (error "Point is inside a %s"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1355 (nxml-token-type-friendly-name xmltok-type)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1356 (nxml-scan-element-backward token-end t)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1357 (starts-line
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1358 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1359 (unless (eq xmltok-type 'start-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1360 (error "No matching start-tag"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1361 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1362 (back-to-indentation)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1363 (eq (point) xmltok-start)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1364 (ends-line
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1365 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1366 (goto-char start-tag-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1367 (looking-at "[ \t\r\n]*$")))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1368 (start-tag-indent (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1369 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1370 (current-column)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1371 (qname (xmltok-start-tag-qname))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1372 inserted-start-tag-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1373 (when (and starts-line ends-line)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1374 ;; start-tag is on a line by itself
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1375 ;; => put the end-tag on a line by itself
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1376 (unless (<= (point)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1377 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1378 (back-to-indentation)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1379 (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1380 (insert "\n"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1381 (indent-line-to start-tag-indent))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1382 (insert "</" qname ">")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1383 (when startp
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1384 (when starts-line
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1385 (insert "\n")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1386 (indent-line-to start-tag-indent))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1387 (setq inserted-start-tag-pos (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1388 (insert "<" qname ">")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1389 (when (and starts-line ends-line)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1390 (insert "\n")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1391 (indent-line-to (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1392 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1393 (forward-line 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1394 (back-to-indentation)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1395 (if (= (current-column)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1396 (+ start-tag-indent nxml-child-indent))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1397 (+ start-tag-indent nxml-child-indent)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1398 start-tag-indent)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1399 inserted-start-tag-pos))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1400
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1401 ;;; Indentation
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1402
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1403 (defun nxml-indent-line ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1404 "Indent current line as XML."
108987
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1405 (let* ((savep (point))
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1406 (indent (condition-case nil
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1407 (save-excursion
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1408 (forward-line 0)
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1409 (skip-chars-forward " \t")
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1410 (if (>= (point) savep) (setq savep nil))
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1411 (or (nxml-compute-indent) 0))
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1412 (error 0))))
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1413 (if (not (numberp indent))
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1414 ;; If something funny is used (e.g. `noindent'), return it.
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1415 indent
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1416 (if (< indent 0) (setq indent 0)) ;Just in case.
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1417 (if savep
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1418 (save-excursion (indent-line-to indent))
18cf7a828b34 * lisp/nxml/nxml-mode.el (nxml-indent-line): Standardize indent behavior.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108714
diff changeset
1419 (indent-line-to indent)))))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1420
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1421 (defun nxml-compute-indent ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1422 "Return the indent for the line containing point."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1423 (or (nxml-compute-indent-from-matching-start-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1424 (nxml-compute-indent-from-previous-line)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1425
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1426 (defun nxml-compute-indent-from-matching-start-tag ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1427 "Compute the indent for a line with an end-tag using the matching start-tag.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1428 When the line containing point ends with an end-tag and does not start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1429 in the middle of a token, return the indent of the line containing the
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1430 matching start-tag, if there is one and it occurs at the beginning of
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1431 its line. Otherwise return nil."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1432 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1433 (back-to-indentation)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1434 (let ((bol (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1435 (let ((inhibit-field-text-motion t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1436 (end-of-line))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1437 (skip-chars-backward " \t")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1438 (and (= (nxml-token-before) (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1439 (memq xmltok-type '(end-tag partial-end-tag))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1440 ;; start of line must not be inside a token
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1441 (or (= xmltok-start bol)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1442 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1443 (goto-char bol)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1444 (nxml-token-after)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1445 (= xmltok-start bol))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1446 (eq xmltok-type 'data))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1447 (condition-case err
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1448 (nxml-scan-element-backward
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1449 (point)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1450 nil
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1451 (- (point)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1452 nxml-end-tag-indent-scan-distance))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1453 (nxml-scan-error nil))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1454 (< xmltok-start bol)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1455 (progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1456 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1457 (skip-chars-backward " \t")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1458 (bolp))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1459 (current-indentation)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1460
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1461 (defun nxml-compute-indent-from-previous-line ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1462 "Compute the indent for a line using the indentation of a previous line."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1463 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1464 (end-of-line)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1465 (let ((eol (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1466 bol prev-bol ref
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1467 before-context after-context)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1468 (back-to-indentation)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1469 (setq bol (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1470 (catch 'indent
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1471 ;; Move backwards until the start of a non-blank line that is
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1472 ;; not inside a token.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1473 (while (progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1474 (when (= (forward-line -1) -1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1475 (throw 'indent 0))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1476 (back-to-indentation)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1477 (if (looking-at "[ \t]*$")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1478 t
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1479 (or prev-bol
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1480 (setq prev-bol (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1481 (nxml-token-after)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1482 (not (or (= xmltok-start (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1483 (eq xmltok-type 'data))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1484 (setq ref (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1485 ;; Now scan over tokens until the end of the line to be indented.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1486 ;; Determine the context before and after the beginning of the
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1487 ;; line.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1488 (while (< (point) eol)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1489 (nxml-tokenize-forward)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1490 (cond ((<= bol xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1491 (setq after-context
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1492 (nxml-merge-indent-context-type after-context)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1493 ((and (<= (point) bol)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1494 (not (and (eq xmltok-type 'partial-start-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1495 (= (point) bol))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1496 (setq before-context
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1497 (nxml-merge-indent-context-type before-context)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1498 ((eq xmltok-type 'data)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1499 (setq before-context
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1500 (nxml-merge-indent-context-type before-context))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1501 (setq after-context
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1502 (nxml-merge-indent-context-type after-context)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1503 ;; If in the middle of a token that looks inline,
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1504 ;; then indent relative to the previous non-blank line
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1505 ((eq (nxml-merge-indent-context-type before-context)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1506 'mixed)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1507 (goto-char prev-bol)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1508 (throw 'indent (current-column)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1509 (t
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1510 (throw 'indent
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1511 (nxml-compute-indent-in-token bol))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1512 (skip-chars-forward " \t\r\n"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1513 (goto-char ref)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1514 (+ (current-column)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1515 (* nxml-child-indent
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1516 (+ (if (eq before-context 'start-tag) 1 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1517 (if (eq after-context 'end-tag) -1 0))))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1518
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1519 (defun nxml-merge-indent-context-type (context)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1520 "Merge the indent context type CONTEXT with the token in `xmltok-type'.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1521 Return the merged indent context type. An indent context type is
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
1522 either nil or one of the symbols `start-tag', `end-tag', `markup',
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
1523 `comment', `mixed'."
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1524 (cond ((memq xmltok-type '(start-tag partial-start-tag))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1525 (if (memq context '(nil start-tag comment))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1526 'start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1527 'mixed))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1528 ((memq xmltok-type '(end-tag partial-end-tag))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1529 (if (memq context '(nil end-tag comment))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1530 'end-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1531 'mixed))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1532 ((eq xmltok-type 'comment)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1533 (cond ((memq context '(start-tag end-tag comment))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1534 context)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1535 (context 'mixed)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1536 (t 'comment)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1537 (context 'mixed)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1538 (t 'markup)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1539
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1540 (defun nxml-compute-indent-in-token (pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1541 "Return the indent for a line that starts inside a token.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1542 POS is the position of the first non-whitespace character of the line.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1543 This expects the xmltok-* variables to be set up as by `xmltok-forward'."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1544 (cond ((memq xmltok-type '(start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1545 partial-start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1546 empty-element
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1547 partial-empty-element))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1548 (nxml-compute-indent-in-start-tag pos))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1549 ((eq xmltok-type 'comment)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1550 (nxml-compute-indent-in-delimited-token pos "<!--" "-->"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1551 ((eq xmltok-type 'cdata-section)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1552 (nxml-compute-indent-in-delimited-token pos "<![CDATA[" "]]>"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1553 ((eq xmltok-type 'processing-instruction)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1554 (nxml-compute-indent-in-delimited-token pos "<?" "?>"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1555 (t
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1556 (goto-char pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1557 (if (and (= (forward-line -1) 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1558 (< xmltok-start (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1559 (back-to-indentation)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1560 (goto-char xmltok-start))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1561 (current-column))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1562
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1563 (defun nxml-compute-indent-in-start-tag (pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1564 "Return the indent for a line that starts inside a start-tag.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1565 Also for a line that starts inside an empty element.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1566 POS is the position of the first non-whitespace character of the line.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1567 This expects the xmltok-* variables to be set up as by `xmltok-forward'."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1568 (let ((value-boundary (nxml-attribute-value-boundary pos))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1569 (off 0))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1570 (if value-boundary
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1571 ;; inside an attribute value
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1572 (let ((value-start (car value-boundary))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1573 (value-end (cdr value-boundary)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1574 (goto-char pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1575 (forward-line -1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1576 (if (< (point) value-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1577 (goto-char value-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1578 (back-to-indentation)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1579 ;; outside an attribute value
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1580 (goto-char pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1581 (while (and (= (forward-line -1) 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1582 (nxml-attribute-value-boundary (point))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1583 (cond ((<= (point) xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1584 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1585 (setq off nxml-attribute-indent)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1586 (let ((atts (xmltok-merge-attributes)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1587 (when atts
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1588 (let* ((att (car atts))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1589 (start (xmltok-attribute-name-start att)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1590 (when (< start pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1591 (goto-char start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1592 (setq off 0))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1593 (t
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1594 (back-to-indentation))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1595 (+ (current-column) off)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1596
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1597 (defun nxml-attribute-value-boundary (pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1598 "Return a pair (START . END) if POS is inside an attribute value.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1599 Otherwise return nil. START and END are the positions of the start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1600 and end of the attribute value containing POS. This expects the
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1601 xmltok-* variables to be set up as by `xmltok-forward'."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1602 (let ((atts (xmltok-merge-attributes))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1603 att value-start value-end value-boundary)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1604 (while atts
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1605 (setq att (car atts))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1606 (setq value-start (xmltok-attribute-value-start att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1607 (setq value-end (xmltok-attribute-value-end att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1608 (cond ((and value-start (< pos value-start))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1609 (setq atts nil))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1610 ((and value-start value-end (<= pos value-end))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1611 (setq value-boundary (cons value-start value-end))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1612 (setq atts nil))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1613 (t (setq atts (cdr atts)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1614 value-boundary))
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
1615
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1616 (defun nxml-compute-indent-in-delimited-token (pos open-delim close-delim)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1617 "Return the indent for a line that starts inside a token with delimiters.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1618 OPEN-DELIM and CLOSE-DELIM are strings giving the opening and closing
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1619 delimiters. POS is the position of the first non-whitespace character
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1620 of the line. This expects the xmltok-* variables to be set up as by
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1621 `xmltok-forward'."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1622 (cond ((let ((end (+ pos (length close-delim))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1623 (and (<= end (point-max))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1624 (string= (buffer-substring-no-properties pos end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1625 close-delim)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1626 (goto-char xmltok-start))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1627 ((progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1628 (goto-char pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1629 (forward-line -1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1630 (<= (point) xmltok-start))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1631 (goto-char (+ xmltok-start (length open-delim)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1632 (when (and (string= open-delim "<!--")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1633 (looking-at " "))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1634 (goto-char (1+ (point)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1635 (t (back-to-indentation)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1636 (current-column))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1637
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1638 ;;; Completion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1639
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1640 (defun nxml-complete ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1641 "Perform completion on the symbol preceding point.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1642
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1643 Inserts as many characters as can be completed. However, if not even
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1644 one character can be completed, then a buffer with the possibilities
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1645 is popped up and the symbol is read from the minibuffer with
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
1646 completion. If the symbol is complete, then any characters that must
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1647 follow the symbol are also inserted.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1648
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1649 The name space used for completion and what is treated as a symbol
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1650 depends on the context. The contexts in which completion is performed
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1651 depend on `nxml-completion-hook'."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1652 (interactive)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1653 (unless (run-hook-with-args-until-success 'nxml-completion-hook)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1654 ;; Eventually we will complete on entity names here.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1655 (ding)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1656 (message "Cannot complete in this context")))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1657
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1658 ;;; Movement
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1659
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1660 (defun nxml-forward-balanced-item (&optional arg)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1661 "Move forward across one balanced item.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1662 With ARG, do it that many times. Negative arg -N means
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1663 move backward across N balanced expressions.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1664 This is the equivalent of `forward-sexp' for XML.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1665
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1666 An element contains as items strings with no markup, tags, processing
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1667 instructions, comments, CDATA sections, entity references and
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
1668 characters references. However, if the variable
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1669 `nxml-sexp-element-flag' is non-nil, then an element is treated as a
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1670 single markup item. A start-tag contains an element name followed by
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
1671 one or more attributes. An end-tag contains just an element name.
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
1672 An attribute value literals contains strings with no markup, entity
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1673 references and character references. A processing instruction
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1674 consists of a target and a content string. A comment or a CDATA
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1675 section contains a single string. An entity reference contains a
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1676 single name. A character reference contains a character number."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1677 (interactive "p")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1678 (or arg (setq arg 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1679 (cond ((> arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1680 (while (progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1681 (nxml-forward-single-balanced-item)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1682 (> (setq arg (1- arg)) 0))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1683 ((< arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1684 (while (progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1685 (nxml-backward-single-balanced-item)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1686 (< (setq arg (1+ arg)) 0))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1687
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1688 (defun nxml-forward-single-balanced-item ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1689 (condition-case err
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1690 (goto-char (let ((end (nxml-token-after)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1691 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1692 (while (eq xmltok-type 'space)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1693 (goto-char end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1694 (setq end (nxml-token-after)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1695 (cond ((/= (point) xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1696 (nxml-scan-forward-within end))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1697 ((and nxml-sexp-element-flag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1698 (eq xmltok-type 'start-tag))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1699 ;; can't ever return nil here
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1700 (nxml-scan-element-forward xmltok-start))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1701 ((and nxml-sexp-element-flag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1702 (memq xmltok-type
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1703 '(end-tag partial-end-tag)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1704 (error "Already at end of element"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1705 (t end)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1706 (nxml-scan-error
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1707 (goto-char (cadr err))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1708 (apply 'error (cddr err)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1709
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1710 (defun nxml-backward-single-balanced-item ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1711 (condition-case err
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1712 (goto-char (let ((end (nxml-token-before)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1713 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1714 (while (eq xmltok-type 'space)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1715 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1716 (setq end (nxml-token-before)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1717 (cond ((/= (point) end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1718 (nxml-scan-backward-within end))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1719 ((and nxml-sexp-element-flag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1720 (eq xmltok-type 'end-tag))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1721 ;; can't ever return nil here
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1722 (nxml-scan-element-backward end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1723 xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1724 ((and nxml-sexp-element-flag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1725 (eq xmltok-type 'start-tag))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1726 (error "Already at start of element"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1727 (t xmltok-start)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1728 (nxml-scan-error
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1729 (goto-char (cadr err))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1730 (apply 'error (cddr err)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1731
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1732 (defun nxml-scan-forward-within (end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1733 (setq end (- end (nxml-end-delimiter-length xmltok-type)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1734 (when (<= end (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1735 (error "Already at end of %s"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1736 (nxml-token-type-friendly-name xmltok-type)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1737 (cond ((memq xmltok-type '(start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1738 empty-element
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1739 partial-start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1740 partial-empty-element))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1741 (if (< (point) xmltok-name-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1742 xmltok-name-end
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1743 (let ((att (nxml-find-following-attribute)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1744 (cond ((not att) end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1745 ((and (xmltok-attribute-value-start att)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1746 (<= (xmltok-attribute-value-start att)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1747 (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1748 (nxml-scan-forward-in-attribute-value att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1749 ((xmltok-attribute-value-end att)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1750 (1+ (xmltok-attribute-value-end att)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1751 ((save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1752 (goto-char (xmltok-attribute-name-end att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1753 (looking-at "[ \t\r\n]*="))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1754 (match-end 0))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1755 (t (xmltok-attribute-name-end att))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1756 ((and (eq xmltok-type 'processing-instruction)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1757 (< (point) xmltok-name-end))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1758 xmltok-name-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1759 (t end)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1760
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1761 (defun nxml-scan-backward-within (end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1762 (setq xmltok-start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1763 (+ xmltok-start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1764 (nxml-start-delimiter-length xmltok-type)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1765 (when (<= (point) xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1766 (error "Already at start of %s"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1767 (nxml-token-type-friendly-name xmltok-type)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1768 (cond ((memq xmltok-type '(start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1769 empty-element
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1770 partial-start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1771 partial-empty-element))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1772 (let ((att (nxml-find-preceding-attribute)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1773 (cond ((not att) xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1774 ((and (xmltok-attribute-value-start att)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1775 (<= (xmltok-attribute-value-start att)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1776 (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1777 (<= (point)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1778 (xmltok-attribute-value-end att)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1779 (nxml-scan-backward-in-attribute-value att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1780 (t (xmltok-attribute-name-start att)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1781 ((and (eq xmltok-type 'processing-instruction)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1782 (let ((content-start (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1783 (goto-char xmltok-name-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1784 (skip-chars-forward " \r\t\n")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1785 (point))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1786 (and (< content-start (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1787 content-start))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1788 (t xmltok-start)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1789
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1790 (defun nxml-scan-forward-in-attribute-value (att)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1791 (when (= (point) (xmltok-attribute-value-end att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1792 (error "Already at end of attribute value"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1793 (let ((refs (xmltok-attribute-refs att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1794 ref)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1795 (while refs
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1796 (setq ref (car refs))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1797 (if (< (point) (aref ref 2))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1798 (setq refs nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1799 (setq ref nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1800 (setq refs (cdr refs))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1801 (cond ((not ref)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1802 (xmltok-attribute-value-end att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1803 ((< (point) (aref ref 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1804 (aref ref 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1805 ((= (point) (aref ref 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1806 (aref ref 2))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1807 (t
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1808 (let ((end (- (aref ref 2)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1809 (nxml-end-delimiter-length (aref ref 0)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1810 (if (< (point) end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1811 end
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1812 (error "Already at end of %s"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1813 (nxml-token-type-friendly-name (aref ref 0)))))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1814
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1815 (defun nxml-scan-backward-in-attribute-value (att)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1816 (when (= (point) (xmltok-attribute-value-start att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1817 (error "Already at start of attribute value"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1818 (let ((refs (reverse (xmltok-attribute-refs att)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1819 ref)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1820 (while refs
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1821 (setq ref (car refs))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1822 (if (< (aref ref 1) (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1823 (setq refs nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1824 (setq ref nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1825 (setq refs (cdr refs))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1826 (cond ((not ref)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1827 (xmltok-attribute-value-start att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1828 ((< (aref ref 2) (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1829 (aref ref 2))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1830 ((= (point) (aref ref 2))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1831 (aref ref 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1832 (t
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1833 (let ((start (+ (aref ref 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1834 (nxml-start-delimiter-length (aref ref 0)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1835 (if (< start (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1836 start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1837 (error "Already at start of %s"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1838 (nxml-token-type-friendly-name (aref ref 0)))))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1839
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1840 (defun nxml-find-following-attribute ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1841 (let ((ret nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1842 (atts (or xmltok-attributes xmltok-namespace-attributes))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1843 (more-atts (and xmltok-attributes xmltok-namespace-attributes)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1844 (while atts
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1845 (let* ((att (car atts))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1846 (name-start (xmltok-attribute-name-start att)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1847 (cond ((and (<= name-start (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1848 (xmltok-attribute-value-end att)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1849 ;; <= because end is before quote
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1850 (<= (point) (xmltok-attribute-value-end att)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1851 (setq atts nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1852 (setq ret att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1853 ((and (< (point) name-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1854 (or (not ret)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1855 (< name-start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1856 (xmltok-attribute-name-start ret))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1857 (setq ret att))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1858 (setq atts (cdr atts))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1859 (unless atts
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1860 (setq atts more-atts)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1861 (setq more-atts nil)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1862 ret))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1863
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1864 (defun nxml-find-preceding-attribute ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1865 (let ((ret nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1866 (atts (or xmltok-attributes xmltok-namespace-attributes))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1867 (more-atts (and xmltok-attributes xmltok-namespace-attributes)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1868 (while atts
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1869 (let* ((att (car atts))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1870 (name-start (xmltok-attribute-name-start att)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1871 (cond ((and (< name-start (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1872 (xmltok-attribute-value-end att)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1873 ;; <= because end is before quote
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1874 (<= (point) (xmltok-attribute-value-end att)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1875 (setq atts nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1876 (setq ret att))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1877 ((and (< name-start (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1878 (or (not ret)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1879 (< (xmltok-attribute-name-start ret)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1880 name-start)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1881 (setq ret att))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1882 (setq atts (cdr atts))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1883 (unless atts
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1884 (setq atts more-atts)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1885 (setq more-atts nil)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1886 ret))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1887
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1888 (defun nxml-up-element (&optional arg)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1889 (interactive "p")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1890 (or arg (setq arg 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1891 (if (< arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1892 (nxml-backward-up-element (- arg))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1893 (condition-case err
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1894 (while (and (> arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1895 (< (point) (point-max)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1896 (let ((token-end (nxml-token-after)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1897 (goto-char (cond ((or (memq xmltok-type '(end-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1898 partial-end-tag))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1899 (and (memq xmltok-type
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1900 '(empty-element
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1901 partial-empty-element))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1902 (< xmltok-start (point))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1903 token-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1904 ((nxml-scan-element-forward
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1905 (if (and (eq xmltok-type 'start-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1906 (= (point) xmltok-start))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1907 xmltok-start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1908 token-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1909 t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1910 (t (error "No parent element")))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1911 (setq arg (1- arg)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1912 (nxml-scan-error
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1913 (goto-char (cadr err))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1914 (apply 'error (cddr err))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1915
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1916 (defun nxml-backward-up-element (&optional arg)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1917 (interactive "p")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1918 (or arg (setq arg 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1919 (if (< arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1920 (nxml-up-element (- arg))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1921 (condition-case err
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1922 (while (and (> arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1923 (< (point-min) (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1924 (let ((token-end (nxml-token-before)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1925 (goto-char (cond ((or (memq xmltok-type '(start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1926 partial-start-tag))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1927 (and (memq xmltok-type
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1928 '(empty-element
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1929 partial-empty-element))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1930 (< (point) token-end)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1931 xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1932 ((nxml-scan-element-backward
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1933 (if (and (eq xmltok-type 'end-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1934 (= (point) token-end))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1935 token-end
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1936 xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1937 t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1938 xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1939 (t (error "No parent element")))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1940 (setq arg (1- arg)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1941 (nxml-scan-error
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1942 (goto-char (cadr err))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1943 (apply 'error (cddr err))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1944
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1945 (defun nxml-down-element (&optional arg)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1946 "Move forward down into the content of an element.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1947 With ARG, do this that many times.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1948 Negative ARG means move backward but still down."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1949 (interactive "p")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1950 (or arg (setq arg 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1951 (if (< arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1952 (nxml-backward-down-element (- arg))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1953 (while (> arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1954 (goto-char
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1955 (let ((token-end (nxml-token-after)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1956 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1957 (goto-char token-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1958 (while (progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1959 (when (memq xmltok-type '(nil end-tag partial-end-tag))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1960 (error "No following start-tags in this element"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1961 (not (memq xmltok-type '(start-tag partial-start-tag))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1962 (nxml-tokenize-forward))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1963 (point))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1964 (setq arg (1- arg)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1965
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1966 (defun nxml-backward-down-element (&optional arg)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1967 (interactive "p")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1968 (or arg (setq arg 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1969 (if (< arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1970 (nxml-down-element (- arg))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1971 (while (> arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1972 (goto-char
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1973 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1974 (nxml-token-before)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1975 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1976 (while (progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1977 (when (memq xmltok-type '(start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1978 partial-start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1979 prolog
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1980 nil))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1981 (error "No preceding end-tags in this element"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1982 (not (memq xmltok-type '(end-tag partial-end-tag))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1983 (if (or (<= (point) nxml-prolog-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1984 (not (search-backward "<" nxml-prolog-end t)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1985 (setq xmltok-type nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1986 (nxml-move-outside-backwards)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1987 (xmltok-forward)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1988 xmltok-start))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1989 (setq arg (1- arg)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1990
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1991 (defun nxml-forward-element (&optional arg)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1992 "Move forward over one element.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1993 With ARG, do it that many times.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1994 Negative ARG means move backward."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1995 (interactive "p")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1996 (or arg (setq arg 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1997 (if (< arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1998 (nxml-backward-element (- arg))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
1999 (condition-case err
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2000 (while (and (> arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2001 (< (point) (point-max)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2002 (goto-char
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2003 (or (nxml-scan-element-forward (nxml-token-before))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2004 (error "No more elements")))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2005 (setq arg (1- arg)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2006 (nxml-scan-error
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2007 (goto-char (cadr err))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2008 (apply 'error (cddr err))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2009
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2010 (defun nxml-backward-element (&optional arg)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2011 "Move backward over one element.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2012 With ARG, do it that many times.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2013 Negative ARG means move forward."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2014 (interactive "p")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2015 (or arg (setq arg 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2016 (if (< arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2017 (nxml-forward-element (- arg))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2018 (condition-case err
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2019 (while (and (> arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2020 (< (point-min) (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2021 (goto-char
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2022 (or (and (nxml-scan-element-backward (progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2023 (nxml-token-after)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2024 xmltok-start))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2025 xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2026 (error "No preceding elements")))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2027 (setq arg (1- arg)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2028 (nxml-scan-error
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2029 (goto-char (cadr err))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2030 (apply 'error (cddr err))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2031
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2032 (defun nxml-mark-token-after ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2033 (interactive)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2034 (push-mark (nxml-token-after) nil t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2035 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2036 (message "Marked %s" xmltok-type))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2037
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2038 ;;; Paragraphs
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2039
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2040 (defun nxml-mark-paragraph ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2041 "Put point at beginning of this paragraph, mark at end.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2042 The paragraph marked is the one that contains point or follows point."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2043 (interactive)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2044 (nxml-forward-paragraph)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2045 (push-mark nil t t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2046 (nxml-backward-paragraph))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2047
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2048 (defun nxml-forward-paragraph (&optional arg)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2049 (interactive "p")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2050 (or arg (setq arg 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2051 (cond ((< arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2052 (nxml-backward-paragraph (- arg)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2053 ((> arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2054 (forward-line 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2055 (while (and (nxml-forward-single-paragraph)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2056 (> (setq arg (1- arg)) 0))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2057
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2058 (defun nxml-backward-paragraph (&optional arg)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2059 (interactive "p")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2060 (or arg (setq arg 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2061 (cond ((< arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2062 (nxml-forward-paragraph (- arg)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2063 ((> arg 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2064 (unless (bolp)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2065 (let ((inhibit-field-text-motion t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2066 (end-of-line)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2067 (while (and (nxml-backward-single-paragraph)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2068 (> (setq arg (1- arg)) 0))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2069
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2070 (defun nxml-forward-single-paragraph ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2071 "Move forward over a single paragraph.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2072 Return nil at end of buffer, t otherwise."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2073 (let* ((token-end (nxml-token-after))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2074 (offset (- (point) xmltok-start))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2075 pos had-data)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2076 (goto-char token-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2077 (while (and (< (point) (point-max))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2078 (not (setq pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2079 (nxml-paragraph-end-pos had-data offset))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2080 (when (nxml-token-contains-data-p offset)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2081 (setq had-data t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2082 (nxml-tokenize-forward)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2083 (setq offset 0))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2084 (when pos (goto-char pos))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2085
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2086 (defun nxml-backward-single-paragraph ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2087 "Move backward over a single paragraph.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2088 Return nil at start of buffer, t otherwise."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2089 (let* ((token-end (nxml-token-before))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2090 (offset (- token-end (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2091 (last-tag-pos xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2092 pos had-data last-data-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2093 (goto-char token-end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2094 (unless (setq pos (nxml-paragraph-start-pos nil offset))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2095 (setq had-data (nxml-token-contains-data-p nil offset))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2096 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2097 (while (and (not pos) (< (point-min) (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2098 (cond ((search-backward "<" nxml-prolog-end t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2099 (nxml-move-outside-backwards)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2100 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2101 (while (< (point) last-tag-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2102 (xmltok-forward)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2103 (when (and (not had-data) (nxml-token-contains-data-p))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2104 (setq pos nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2105 (setq last-data-pos xmltok-start))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2106 (let ((tem (nxml-paragraph-start-pos had-data 0)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2107 (when tem (setq pos tem)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2108 (when (and (not had-data) last-data-pos (not pos))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2109 (setq had-data t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2110 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2111 (while (< (point) last-data-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2112 (xmltok-forward))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2113 (let ((tem (nxml-paragraph-start-pos had-data 0)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2114 (when tem (setq pos tem)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2115 (setq last-tag-pos (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2116 (t (goto-char (point-min))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2117 (when pos (goto-char pos))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2118
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2119 (defun nxml-token-contains-data-p (&optional start end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2120 (setq start (+ xmltok-start (or start 0)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2121 (setq end (- (point) (or end 0)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2122 (when (eq xmltok-type 'cdata-section)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2123 (setq start (max start (+ xmltok-start 9)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2124 (setq end (min end (- (point) 3))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2125 (or (and (eq xmltok-type 'data)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2126 (eq start xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2127 (eq end (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2128 (eq xmltok-type 'char-ref)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2129 (and (memq xmltok-type '(data cdata-section))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2130 (< start end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2131 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2132 (goto-char start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2133 (re-search-forward "[^ \t\r\n]" end t)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2134
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2135 (defun nxml-paragraph-end-pos (had-data offset)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2136 "Return the position of the paragraph end if contained in the current token.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2137 Return nil if the current token does not contain the paragraph end.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2138 Only characters after OFFSET from the start of the token are eligible.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2139 HAD-DATA says whether there have been non-whitespace data characters yet."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2140 (cond ((not had-data)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2141 (cond ((memq xmltok-type '(data cdata-section))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2142 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2143 (let ((end (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2144 (goto-char (+ xmltok-start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2145 (max (if (eq xmltok-type 'cdata-section)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2146 9
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2147 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2148 offset)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2149 (and (re-search-forward "[^ \t\r\n]" end t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2150 (re-search-forward "^[ \t]*$" end t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2151 (match-beginning 0)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2152 ((and (eq xmltok-type 'comment)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2153 (nxml-token-begins-line-p)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2154 (nxml-token-ends-line-p))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2155 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2156 (let ((end (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2157 (goto-char (+ xmltok-start (max 4 offset)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2158 (when (re-search-forward "[^ \t\r\n]" (- end 3) t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2159 (if (re-search-forward "^[ \t]*$" end t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2160 (match-beginning 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2161 (goto-char (- end 3))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2162 (skip-chars-backward " \t")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2163 (unless (bolp)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2164 (beginning-of-line 2))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2165 (point))))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2166 ((memq xmltok-type '(data space cdata-section))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2167 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2168 (let ((end (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2169 (goto-char (+ xmltok-start offset))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2170 (and (re-search-forward "^[ \t]*$" end t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2171 (match-beginning 0)))))
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2172 ((and (memq xmltok-type '(start-tag
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2173 end-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2174 empty-element
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2175 comment
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2176 processing-instruction
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2177 entity-ref))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2178 (nxml-token-begins-line-p)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2179 (nxml-token-ends-line-p))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2180 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2181 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2182 (skip-chars-backward " \t")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2183 (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2184 ((and (eq xmltok-type 'end-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2185 (looking-at "[ \t]*$")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2186 (not (nxml-in-mixed-content-p t)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2187 (save-excursion
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2188 (or (search-forward "\n" nil t)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2189 (point-max))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2190
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2191 (defun nxml-paragraph-start-pos (had-data offset)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2192 "Return the position of the paragraph start if contained in the current token.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2193 Return nil if the current token does not contain the paragraph start.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2194 Only characters before OFFSET from the end of the token are eligible.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2195 HAD-DATA says whether there have been non-whitespace data characters yet."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2196 (cond ((not had-data)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2197 (cond ((memq xmltok-type '(data cdata-section))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2198 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2199 (goto-char (- (point)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2200 (max (if (eq xmltok-type 'cdata-section)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2201 3
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2202 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2203 offset)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2204 (and (re-search-backward "[^ \t\r\n]" xmltok-start t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2205 (re-search-backward "^[ \t]*$" xmltok-start t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2206 (match-beginning 0))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2207 ((and (eq xmltok-type 'comment)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2208 (nxml-token-ends-line-p)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2209 (nxml-token-begins-line-p))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2210 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2211 (goto-char (- (point) (max 3 offset)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2212 (when (and (< (+ xmltok-start 4) (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2213 (re-search-backward "[^ \t\r\n]"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2214 (+ xmltok-start 4)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2215 t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2216 (if (re-search-backward "^[ \t]*$" xmltok-start t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2217 (match-beginning 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2218 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2219 (if (looking-at "<!--[ \t]*\n")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2220 (match-end 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2221 (skip-chars-backward " \t")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2222 (point))))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2223 ((memq xmltok-type '(data space cdata-section))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2224 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2225 (goto-char (- (point) offset))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2226 (and (re-search-backward "^[ \t]*$" xmltok-start t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2227 (match-beginning 0))))
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2228 ((and (memq xmltok-type '(start-tag
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2229 end-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2230 empty-element
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2231 comment
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2232 processing-instruction
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2233 entity-ref))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2234 (nxml-token-ends-line-p)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2235 (nxml-token-begins-line-p))
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2236 (or (search-forward "\n" nil t)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2237 (point-max)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2238 ((and (eq xmltok-type 'start-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2239 (nxml-token-begins-line-p)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2240 (not (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2241 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2242 (nxml-in-mixed-content-p nil))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2243 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2244 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2245 (skip-chars-backward " \t")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2246 ;; include any blank line before
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2247 (or (and (eq (char-before) ?\n)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2248 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2249 (goto-char (1- (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2250 (skip-chars-backward " \t")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2251 (and (bolp) (point))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2252 (point))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2253
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2254 (defun nxml-token-ends-line-p () (looking-at "[ \t]*$"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2255
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2256 (defun nxml-token-begins-line-p ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2257 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2258 (goto-char xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2259 (skip-chars-backward " \t")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2260 (bolp)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2261
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2262 (defun nxml-in-mixed-content-p (endp)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2263 "Return non-nil if point is in mixed content.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2264 Point must be after an end-tag or before a start-tag.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2265 ENDP is t in the former case, nil in the latter."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2266 (let (matching-tag-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2267 (cond ((not (run-hook-with-args-until-failure
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2268 'nxml-in-mixed-content-hook))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2269 nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2270 ;; See if the matching tag does not start or end a line.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2271 ((condition-case err
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2272 (progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2273 (setq matching-tag-pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2274 (xmltok-save
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2275 (if endp
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2276 (and (nxml-scan-element-backward (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2277 xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2278 (nxml-scan-element-forward (point)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2279 (and matching-tag-pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2280 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2281 (goto-char matching-tag-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2282 (not (if endp
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2283 (progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2284 (skip-chars-backward " \t")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2285 (bolp))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2286 (looking-at "[ \t]*$"))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2287 (nxml-scan-error nil))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2288 t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2289 ;; See if there's data at the same level.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2290 ((let (start end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2291 (if endp
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2292 (setq start matching-tag-pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2293 end (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2294 (setq start (point)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2295 end matching-tag-pos))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2296 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2297 (or (when start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2298 (goto-char start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2299 (nxml-preceding-sibling-data-p))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2300 (when end
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2301 (goto-char end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2302 (nxml-following-sibling-data-p)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2303 t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2304 ;; Otherwise, treat as not mixed
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2305 (t nil))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2306
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2307 (defun nxml-preceding-sibling-data-p ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2308 "Return non-nil if there is a previous sibling that is data."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2309 (let ((lim (max (- (point) nxml-mixed-scan-distance)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2310 nxml-prolog-end))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2311 (level 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2312 found end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2313 (xmltok-save
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2314 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2315 (while (and (< lim (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2316 (>= level 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2317 (not found)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2318 (progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2319 (setq end (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2320 (search-backward "<" lim t)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2321 (nxml-move-outside-backwards)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2322 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2323 (xmltok-forward)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2324 (let ((prev-level level))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2325 (cond ((eq xmltok-type 'end-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2326 (setq level (1+ level)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2327 ((eq xmltok-type 'start-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2328 (setq level (1- level))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2329 (when (eq prev-level 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2330 (while (and (< (point) end) (not found))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2331 (xmltok-forward)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2332 (when (memq xmltok-type '(data cdata-section char-ref))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2333 (setq found t)))))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2334 found))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2335
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2336 (defun nxml-following-sibling-data-p ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2337 (let ((lim (min (+ (point) nxml-mixed-scan-distance)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2338 (point-max)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2339 (level 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2340 found)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2341 (xmltok-save
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2342 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2343 (while (and (< (point) lim)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2344 (>= level 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2345 (nxml-tokenize-forward)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2346 (not found))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2347 (cond ((eq xmltok-type 'start-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2348 (setq level (1+ level)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2349 ((eq xmltok-type 'end-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2350 (setq level (1- level)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2351 ((and (eq level 0)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2352 (memq xmltok-type '(data cdata-section char-ref)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2353 (setq found t))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2354 found))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2355
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2356 ;;; Filling
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2357
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2358 (defun nxml-do-fill-paragraph (arg)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2359 (let (fill-paragraph-function
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2360 fill-prefix
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2361 start end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2362 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2363 (nxml-forward-paragraph)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2364 (setq end (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2365 (nxml-backward-paragraph)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2366 (skip-chars-forward " \t\r\n")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2367 (setq start (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2368 (beginning-of-line)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2369 (setq fill-prefix (buffer-substring-no-properties (point) start))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2370 (when (and (not (nxml-get-inside (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2371 (looking-at "[ \t]*<!--"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2372 (setq fill-prefix (concat fill-prefix " ")))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2373 (fill-region-as-paragraph start end arg))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2374 (skip-line-prefix fill-prefix)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2375 fill-prefix))
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2376
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2377 (defun nxml-newline-and-indent (soft)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2378 (delete-horizontal-space)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2379 (if soft (insert-and-inherit ?\n) (newline 1))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2380 (nxml-indent-line))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2381
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2382
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2383 ;;; Dynamic markup
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2384
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2385 (defvar nxml-dynamic-markup-prev-pos nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2386 (defvar nxml-dynamic-markup-prev-lengths nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2387 (defvar nxml-dynamic-markup-prev-found-marker nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2388 (defvar nxml-dynamic-markup-prev-start-tags (make-hash-table :test 'equal))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2389
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2390 (defun nxml-dynamic-markup-word ()
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2391 "Dynamically markup the word before point.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2392 This attempts to find a tag to put around the word before point based
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2393 on the contents of the current buffer. The end-tag will be inserted at
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2394 point. The start-tag will be inserted at or before the beginning of
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2395 the word before point; the contents of the current buffer is used to
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2396 decide where.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2397
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2398 It works in a similar way to \\[dabbrev-expand]. It searches first
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2399 backwards from point, then forwards from point for an element whose
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2400 content is a string which matches the contents of the buffer before
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2401 point and which includes at least the word before point. It then
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2402 copies the start- and end-tags from that element and uses them to
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2403 surround the matching string before point.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2404
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2405 Repeating \\[nxml-dynamic-markup-word] immediately after successful
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2406 \\[nxml-dynamic-markup-word] removes the previously inserted markup
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2407 and attempts to find another possible way to do the markup."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2408 (interactive "*")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2409 (let (search-start-pos done)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2410 (if (and (integerp nxml-dynamic-markup-prev-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2411 (= nxml-dynamic-markup-prev-pos (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2412 (eq last-command this-command)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2413 nxml-dynamic-markup-prev-lengths)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2414 (let* ((end-tag-open-pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2415 (- nxml-dynamic-markup-prev-pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2416 (nth 2 nxml-dynamic-markup-prev-lengths)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2417 (start-tag-close-pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2418 (- end-tag-open-pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2419 (nth 1 nxml-dynamic-markup-prev-lengths)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2420 (start-tag-open-pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2421 (- start-tag-close-pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2422 (nth 0 nxml-dynamic-markup-prev-lengths))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2423 (delete-region end-tag-open-pos nxml-dynamic-markup-prev-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2424 (delete-region start-tag-open-pos start-tag-close-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2425 (setq search-start-pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2426 (marker-position nxml-dynamic-markup-prev-found-marker)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2427 (clrhash nxml-dynamic-markup-prev-start-tags))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2428 (setq nxml-dynamic-markup-prev-pos nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2429 (setq nxml-dynamic-markup-prev-lengths nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2430 (setq nxml-dynamic-markup-prev-found-marker nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2431 (goto-char
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2432 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2433 (let* ((pos (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2434 (word (progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2435 (backward-word 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2436 (unless (< (point) pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2437 (error "No word to markup"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2438 (buffer-substring-no-properties (point) pos)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2439 (search (concat word "</"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2440 done)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2441 (when search-start-pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2442 (goto-char search-start-pos))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2443 (while (and (not done)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2444 (or (and (< (point) pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2445 (or (search-backward search nil t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2446 (progn (goto-char pos) nil)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2447 (search-forward search nil t)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2448 (goto-char (- (match-end 0) 2))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2449 (setq done (nxml-try-copy-markup pos)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2450 (or done
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2451 (error (if (zerop (hash-table-count
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2452 nxml-dynamic-markup-prev-start-tags))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2453 "No possible markup found for `%s'"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2454 "No more markup possibilities found for `%s'")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2455 word)))))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2456
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2457 (defun nxml-try-copy-markup (word-end-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2458 (save-excursion
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2459 (let ((end-tag-pos (point)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2460 (when (and (not (nxml-get-inside end-tag-pos))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2461 (search-backward "<" nil t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2462 (not (nxml-get-inside (point))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2463 (xmltok-forward)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2464 (when (and (eq xmltok-type 'start-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2465 (< (point) end-tag-pos))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2466 (let* ((start-tag-close-pos (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2467 (start-tag
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2468 (buffer-substring-no-properties xmltok-start
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2469 start-tag-close-pos))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2470 (words
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2471 (nreverse
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2472 (split-string
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2473 (buffer-substring-no-properties start-tag-close-pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2474 end-tag-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2475 "[ \t\r\n]+"))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2476 (goto-char word-end-pos)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2477 (while (and words
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2478 (re-search-backward (concat
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2479 (regexp-quote (car words))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2480 "\\=")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2481 nil
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2482 t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2483 (setq words (cdr words))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2484 (skip-chars-backward " \t\r\n"))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2485 (when (and (not words)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2486 (progn
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2487 (skip-chars-forward " \t\r\n")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2488 (not (gethash (cons (point) start-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2489 nxml-dynamic-markup-prev-start-tags)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2490 (or (< end-tag-pos (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2491 (< word-end-pos xmltok-start)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2492 (setq nxml-dynamic-markup-prev-found-marker
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2493 (copy-marker end-tag-pos t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2494 (puthash (cons (point) start-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2495 t
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2496 nxml-dynamic-markup-prev-start-tags)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2497 (setq nxml-dynamic-markup-prev-lengths
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2498 (list (- start-tag-close-pos xmltok-start)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2499 (- word-end-pos (point))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2500 (+ (- xmltok-name-end xmltok-start) 2)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2501 (let ((name (xmltok-start-tag-qname)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2502 (insert start-tag)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2503 (goto-char (+ word-end-pos
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2504 (- start-tag-close-pos xmltok-start)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2505 (insert "</" name ">")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2506 (setq nxml-dynamic-markup-prev-pos (point))))))))))
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2507
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2508
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2509 ;;; Character names
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2510
87715
39844b05431b (nxml-char-name-ignore-case): Change default value.
Jason Rumney <jasonr@gnu.org>
parents: 87712
diff changeset
2511 (defvar nxml-char-name-ignore-case t)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2512
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2513 (defvar nxml-char-name-alist nil
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2514 "Alist of character names.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2515 Each member of the list has the form (NAME CODE . NAMESET),
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2516 where NAME is a string naming a character, NAMESET is a symbol
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2517 identifying a set of names and CODE is an integer specifying the
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2518 Unicode scalar value of the named character.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2519 The NAME will only be used for completion if NAMESET has
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2520 a non-nil `nxml-char-name-set-enabled' property.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2521 If NAMESET does does not have `nxml-char-name-set-defined' property,
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2522 then it must have a `nxml-char-name-set-file' property and `load'
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2523 will be applied to the value of this property if the nameset
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2524 is enabled.")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2525
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2526 (defvar nxml-char-name-table (make-hash-table :test 'eq)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2527 "Hash table for mapping char codes to names.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2528 Each key is a Unicode scalar value.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2529 Each value is a list of pairs of the form (NAMESET . NAME),
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2530 where NAMESET is a symbol identifying a set of names,
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2531 and NAME is a string naming a character.")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2532
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2533 (defvar nxml-autoload-char-name-set-list nil
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2534 "List of char namesets that can be autoloaded.")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2535
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2536 (defun nxml-enable-char-name-set (nameset)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2537 (put nameset 'nxml-char-name-set-enabled t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2538
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2539 (defun nxml-disable-char-name-set (nameset)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2540 (put nameset 'nxml-char-name-set-enabled nil))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2541
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2542 (defun nxml-char-name-set-enabled-p (nameset)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2543 (get nameset 'nxml-char-name-set-enabled))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2544
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2545 (defun nxml-autoload-char-name-set (nameset file)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2546 (unless (memq nameset nxml-autoload-char-name-set-list)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2547 (setq nxml-autoload-char-name-set-list
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2548 (cons nameset nxml-autoload-char-name-set-list)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2549 (put nameset 'nxml-char-name-set-file file))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2550
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2551 (defun nxml-define-char-name-set (nameset alist)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2552 "Define a set of character names.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2553 NAMESET is a symbol identifying the set.
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2554 ALIST is a list where each member has the form (NAME CODE),
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2555 where NAME is a string naming a character and code is an
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2556 integer giving the Unicode scalar value of the character."
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2557 (when (get nameset 'nxml-char-name-set-defined)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2558 (error "Nameset `%s' already defined" nameset))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2559 (let ((iter alist))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2560 (while iter
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2561 (let* ((name-code (car iter))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2562 (name (car name-code))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2563 (code (cadr name-code)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2564 (puthash code
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2565 (cons (cons nameset name)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2566 (gethash code nxml-char-name-table))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2567 nxml-char-name-table))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2568 (setcdr (cdr (car iter)) nameset)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2569 (setq iter (cdr iter))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2570 (setq nxml-char-name-alist
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2571 (nconc alist nxml-char-name-alist))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2572 (put nameset 'nxml-char-name-set-defined t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2573
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2574 (defun nxml-get-char-name (code)
86538
57f0d08e5bbe Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
2575 (mapc 'nxml-maybe-load-char-name-set nxml-autoload-char-name-set-list)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2576 (let ((names (gethash code nxml-char-name-table))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2577 name)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2578 (while (and names (not name))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2579 (if (nxml-char-name-set-enabled-p (caar names))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2580 (setq name (cdar names))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2581 (setq names (cdr names))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2582 name))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2583
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2584 (defvar nxml-named-char-history nil)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2585
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2586 (defun nxml-insert-named-char (arg)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2587 "Insert a character using its name.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2588 The name is read from the minibuffer.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2589 Normally, inserts the character as a numeric character reference.
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2590 With a prefix argument, inserts the character directly."
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2591 (interactive "*P")
86538
57f0d08e5bbe Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 86379
diff changeset
2592 (mapc 'nxml-maybe-load-char-name-set nxml-autoload-char-name-set-list)
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2593 (let ((name
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2594 (let ((completion-ignore-case nxml-char-name-ignore-case))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2595 (completing-read "Character name: "
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2596 nxml-char-name-alist
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2597 (lambda (member)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2598 (get (cddr member) 'nxml-char-name-set-enabled))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2599 t
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2600 nil
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2601 'nxml-named-char-history)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2602 (alist nxml-char-name-alist)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2603 elt code)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2604 (while (and alist (not code))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2605 (setq elt (assoc name alist))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2606 (if (get (cddr elt) 'nxml-char-name-set-enabled)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2607 (setq code (cadr elt))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2608 (setq alist (cdr (member elt alist)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2609 (when code
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2610 (insert (if arg
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2611 (or (decode-char 'ucs code)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2612 (error "Character %x is not supported by Emacs"
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2613 code))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2614 (format "&#x%X;" code))))))
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2615
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2616 (defun nxml-maybe-load-char-name-set (sym)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2617 (when (and (get sym 'nxml-char-name-set-enabled)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2618 (not (get sym 'nxml-char-name-set-defined))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2619 (stringp (get sym 'nxml-char-name-set-file)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2620 (load (get sym 'nxml-char-name-set-file))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2621
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2622 (defun nxml-toggle-char-ref-extra-display (arg)
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2623 "Toggle the display of extra information for character references."
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2624 (interactive "P")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2625 (let ((new (if (null arg)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2626 (not nxml-char-ref-extra-display)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2627 (> (prefix-numeric-value arg) 0))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2628 (when (not (eq new nxml-char-ref-extra-display))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2629 (setq nxml-char-ref-extra-display new)
95598
8c4c0ca00399 nXML: Use font lock
Michael Olson <mwolson@gnu.org>
parents: 94666
diff changeset
2630 (font-lock-fontify-buffer))))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2631
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2632 (put 'nxml-char-ref 'evaporate t)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2633
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2634 (defun nxml-char-ref-display-extra (start end n)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2635 (when nxml-char-ref-extra-display
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2636 (let ((name (nxml-get-char-name n))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2637 (glyph-string (and nxml-char-ref-display-glyph-flag
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
2638 (nxml-glyph-display-string n 'nxml-glyph)))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2639 ov)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2640 (when (or name glyph-string)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2641 (setq ov (make-overlay start end nil t))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2642 (overlay-put ov 'category 'nxml-char-ref)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2643 (when name
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2644 (overlay-put ov 'help-echo name))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2645 (when glyph-string
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2646 (overlay-put ov
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2647 'after-string
87348
3d42d5ccb130 (nxml-faces): Rename from nxml-highlighting-faces.
Jason Rumney <jasonr@gnu.org>
parents: 86538
diff changeset
2648 (propertize glyph-string 'face 'nxml-glyph)))))))
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2649
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2650 (defun nxml-clear-char-ref-extra-display (start end)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2651 (let ((ov (overlays-in start end)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2652 (while ov
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2653 (when (eq (overlay-get (car ov) 'category) 'nxml-char-ref)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2654 (delete-overlay (car ov)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2655 (setq ov (cdr ov)))))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2656
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2657
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2658 (defun nxml-start-delimiter-length (type)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2659 (or (get type 'nxml-start-delimiter-length)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2660 0))
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2661
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2662 (put 'cdata-section 'nxml-start-delimiter-length 9)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2663 (put 'comment 'nxml-start-delimiter-length 4)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2664 (put 'processing-instruction 'nxml-start-delimiter-length 2)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2665 (put 'start-tag 'nxml-start-delimiter-length 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2666 (put 'empty-element 'nxml-start-delimiter-length 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2667 (put 'partial-empty-element 'nxml-start-delimiter-length 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2668 (put 'entity-ref 'nxml-start-delimiter-length 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2669 (put 'char-ref 'nxml-start-delimiter-length 2)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2670
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2671 (defun nxml-end-delimiter-length (type)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2672 (or (get type 'nxml-end-delimiter-length)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2673 0))
96496
e374c747704b Fix typos, and general docstring cleanup.
Juanma Barranquero <lekktu@gmail.com>
parents: 96182
diff changeset
2674
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2675 (put 'cdata-section 'nxml-end-delimiter-length 3)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2676 (put 'comment 'nxml-end-delimiter-length 3)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2677 (put 'processing-instruction 'nxml-end-delimiter-length 2)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2678 (put 'start-tag 'nxml-end-delimiter-length 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2679 (put 'empty-element 'nxml-end-delimiter-length 2)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2680 (put 'partial-empty-element 'nxml-end-delimiter-length 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2681 (put 'entity-ref 'nxml-end-delimiter-length 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2682 (put 'char-ref 'nxml-end-delimiter-length 1)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2683
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2684 (defun nxml-token-type-friendly-name (type)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2685 (or (get type 'nxml-friendly-name)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2686 (symbol-name type)))
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2687
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2688 (put 'cdata-section 'nxml-friendly-name "CDATA section")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2689 (put 'processing-instruction 'nxml-friendly-name "processing instruction")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2690 (put 'entity-ref 'nxml-friendly-name "entity reference")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2691 (put 'char-ref 'nxml-friendly-name "character reference")
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2692
105187
064e6af6adba * nxml/nxml-mode.el: Alias xml-mode to nxml-mode.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
2693 ;;;###autoload
064e6af6adba * nxml/nxml-mode.el: Alias xml-mode to nxml-mode.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
2694 (defalias 'xml-mode 'nxml-mode)
064e6af6adba * nxml/nxml-mode.el: Alias xml-mode to nxml-mode.
Chong Yidong <cyd@stupidchicken.com>
parents: 100908
diff changeset
2695
86361
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2696 (provide 'nxml-mode)
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2697
38f93f3d00a2 Initial merge of nxml
Mark A. Hershberger <mah@everybody.org>
parents:
diff changeset
2698 ;;; nxml-mode.el ends here