Mercurial > emacs
annotate lisp/nxml/nxml-util.el @ 95212:a6a4ada91449
* dispextern.h, xfaces.c (xstrcasecmp): Renamed from xstricmp.
* dosfns.c, fileio.c, font.c, fontset.c, image.c, macfns.c:
* macterm.c, process.c, w32.c, w32fns.c, w32proc.c, xfaces.c:
* xfns.c, xfont.c: Callers changed.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Thu, 22 May 2008 14:52:37 +0000 |
parents | d495d4d5452f |
children | 8c4c0ca00399 |
rev | line source |
---|---|
86361 | 1 ;;; nxml-util.el --- utility functions for nxml-*.el |
2 | |
87665 | 3 ;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc. |
86361 | 4 |
5 ;; Author: James Clark | |
6 ;; Keywords: XML | |
7 | |
86544 | 8 ;; This file is part of GNU Emacs. |
9 | |
94666
d495d4d5452f
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87665
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
86544 | 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:
87665
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:
87665
diff
changeset
|
13 ;; (at your option) any later version. |
86361 | 14 |
86544 | 15 ;; GNU Emacs is distributed in the hope that it will be useful, |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
86361 | 19 |
86544 | 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:
87665
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
86361 | 22 |
23 ;;; Commentary: | |
24 | |
25 ;;; Code: | |
26 | |
27 (defun nxml-make-namespace (str) | |
28 "Return a symbol for the namespace URI STR. | |
29 STR must be a string. If STR is the empty string, return nil. | |
30 Otherwise, return the symbol whose name is STR prefixed with a colon." | |
31 (if (string-equal str "") | |
32 nil | |
33 (intern (concat ":" str)))) | |
34 | |
35 (defun nxml-namespace-name (ns) | |
36 "Return the namespace URI corresponding to the symbol NS. | |
37 This is the inverse of `nxml-make-namespace'." | |
38 (and ns (substring (symbol-name ns) 1))) | |
39 | |
40 (defconst nxml-xml-namespace-uri | |
41 (nxml-make-namespace "http://www.w3.org/XML/1998/namespace")) | |
42 | |
43 (defconst nxml-xmlns-namespace-uri | |
44 (nxml-make-namespace "http://www.w3.org/2000/xmlns/")) | |
45 | |
46 (defmacro nxml-with-unmodifying-text-property-changes (&rest body) | |
47 "Evaluate BODY without any text property changes modifying the buffer. | |
48 Any text properties changes happen as usual but the changes are not treated as | |
49 modifications to the buffer." | |
50 (let ((modified (make-symbol "modified"))) | |
51 `(let ((,modified (buffer-modified-p)) | |
52 (inhibit-read-only t) | |
53 (inhibit-modification-hooks t) | |
54 (buffer-undo-list t) | |
55 (deactivate-mark nil) | |
56 ;; Apparently these avoid file locking problems. | |
57 (buffer-file-name nil) | |
58 (buffer-file-truename nil)) | |
59 (unwind-protect | |
60 (progn ,@body) | |
61 (unless ,modified | |
62 (restore-buffer-modified-p nil)))))) | |
63 | |
64 (put 'nxml-with-unmodifying-text-property-changes 'lisp-indent-function 0) | |
65 (def-edebug-spec nxml-with-unmodifying-text-property-changes t) | |
66 | |
67 (defmacro nxml-with-invisible-motion (&rest body) | |
68 "Evaluate body without calling any point motion hooks." | |
69 `(let ((inhibit-point-motion-hooks t)) | |
70 ,@body)) | |
71 | |
72 (put 'nxml-with-invisible-motion 'lisp-indent-function 0) | |
73 (def-edebug-spec nxml-with-invisible-motion t) | |
74 | |
75 (defun nxml-display-file-parse-error (err) | |
76 (let* ((filename (nth 1 err)) | |
77 (buffer (find-file-noselect filename)) | |
78 (pos (nth 2 err)) | |
79 (message (nth 3 err))) | |
80 (pop-to-buffer buffer) | |
81 ;; What's the right thing to do if the buffer's modified? | |
82 ;; The position in the saved file could be completely different. | |
83 (goto-char (if (buffer-modified-p) 1 pos)) | |
84 (error "%s" message))) | |
85 | |
86 (defun nxml-signal-file-parse-error (file pos message &optional error-symbol) | |
87 (signal (or error-symbol 'nxml-file-parse-error) | |
88 (list file pos message))) | |
89 | |
90 (put 'nxml-file-parse-error | |
91 'error-conditions | |
92 '(error nxml-file-parse-error)) | |
93 | |
94 (put 'nxml-parse-file-error | |
95 'error-message | |
96 "Error parsing file") | |
97 | |
98 (provide 'nxml-util) | |
99 | |
86379 | 100 ;; arch-tag: 7d3b3af4-de2b-4410-bf67-94d64824324b |
86361 | 101 ;;; nxml-util.el ends here |