annotate lisp/nxml/nxml-mode.el @ 111782:49c747159b30

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