1 ;;; nxml-mode-os-additions.el --- additional functions for nxml-mode
3 ;; Copyright (C) 2004 by Oliver Steele
5 ;; Author: Oliver Steele <steele@osteele.com>
6 ;; Version: 1.0 (2004-08-08)
7 ;; Homepage: http://osteele.com/sources/nxml-mode-os-additions.el
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2 of
13 ;; the License, or (at your option) any later version.
15 ;; This program is distributed in the hope that it will be
16 ;; useful, but WITHOUT ANY WARRANTY; without even the implied
17 ;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18 ;; PURPOSE. See the GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public
21 ;; License along with this program; if not, write to the Free
22 ;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 ;; nxml-mode-os-additions defines additional functions for using
28 ;; James Clark's nxml-mode:
29 ;; - reload the current buffer's schema
30 ;; - edit the current buffer's schema
34 ;; To use nxml-mode-os-additions.el, put it in your load-path and add
35 ;; the following to your .emacs:
37 ;; (load-library "nxml-mode-os-additions")
41 ;; To make it easier to use, assign the commands to some keys.
42 ;; Once nxml-mode has been loaded, you can define keys on nxml-mode-map.
43 ;; The function rng-mode-os-additions-set-key-bindings illustrates
46 ;; Alternatively, you can place the following in your .emacs:
47 ;; (add-hook 'nxml-mode-hook 'rng-mode-os-additions-set-key-bindings)
51 ;; 2004-08-08 (version 1.0):
52 ;; * Initial public release
54 ;; Added require rng-valid (Lennart Borgman)
59 (eval-and-compile (require 'rng-valid))
61 (defun rng-mode-os-additions-set-key-bindings ()
62 (define-key nxml-mode-map "\C-c\C-s\C-r" 'rng-reload-schema-file)
63 ; move the rng-set-schema-file-and-validate to another key binding
64 ;(define-key nxml-mode-map "\C-c\C-s\C-s" 'rng-set-schema-file-and-validate)
65 (define-key nxml-mode-map "\C-c\C-sf" 'rng-find-schema-file)
68 (defun rng-reload-schema-file ()
69 "Reloads the current schema file."
71 (let ((schema-filename rng-current-schema-file-name))
73 (setq rng-current-schema (rng-load-schema schema-filename))
74 (run-hooks 'rng-schema-change-hook)
75 (message "Reloaded schema %s" schema-filename))
76 (unless schema-filename
77 (rng-set-schema-and-validate))))
79 ;; Helper function for rng-find-schema-file*
80 (defun rng-apply-find-schema-file (fn)
81 (let ((schema-filename rng-current-schema-file-name))
82 (unless schema-filename
83 (error "This file is not associated with a schema file."))
84 (funcall fn schema-filename)))
86 (defun rng-find-schema-file ()
87 "Edit the current schema file."
89 (rng-apply-find-schema-file 'find-file))
91 (defun rng-find-schema-file-other-frame ()
92 "Edit the current schema in another frame."
94 (rng-apply-find-schema-file 'find-file-other-frame))
96 (defun rng-find-schema-file-other-window ()
97 "Edit the current schema in another window."
99 (rng-apply-find-schema-file 'find-file-other-window))