]> git.rkrishnan.org Git - .emacs.d.git/blob - emacs/nxhtml/util/nxml-mode-os-additions.el
0765acfd19417d7c7100ad52cd974e0c2bbb497e
[.emacs.d.git] / emacs / nxhtml / util / nxml-mode-os-additions.el
1 ;;; nxml-mode-os-additions.el --- additional functions for nxml-mode
2
3 ;; Copyright (C) 2004 by Oliver Steele
4
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
8 ;; Keywords: XML
9
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.
14
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.
19
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,
23 ;; MA 02111-1307 USA
24
25 ;;; Description:
26
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
31
32 ;;; Installation:
33 ;;
34 ;; To use nxml-mode-os-additions.el, put it in your load-path and add
35 ;; the following to your .emacs:
36 ;;
37 ;;   (load-library "nxml-mode-os-additions")
38
39 ;; Configuration:
40 ;;
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
44 ;; this.
45 ;;
46 ;; Alternatively, you can place the following in your .emacs:
47 ;;  (add-hook 'nxml-mode-hook 'rng-mode-os-additions-set-key-bindings)
48
49 ;;; ChangeLog:
50 ;;
51 ;; 2004-08-08 (version 1.0):
52 ;;   * Initial public release
53
54 ;; Added require rng-valid (Lennart Borgman)
55
56 ;;; Code:
57
58 (require 'nxml-mode)
59 (eval-and-compile (require 'rng-valid))
60
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)
66   )
67
68 (defun rng-reload-schema-file ()
69   "Reloads the current schema file."
70   (interactive)
71   (let ((schema-filename rng-current-schema-file-name))
72     (when schema-filename
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))))
78
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)))
85
86 (defun rng-find-schema-file ()
87   "Edit the current schema file."
88   (interactive)
89   (rng-apply-find-schema-file 'find-file))
90
91 (defun rng-find-schema-file-other-frame ()
92   "Edit the current schema in another frame."
93   (interactive)
94   (rng-apply-find-schema-file 'find-file-other-frame))
95
96 (defun rng-find-schema-file-other-window ()
97   "Edit the current schema in another window."
98   (interactive)
99   (rng-apply-find-schema-file 'find-file-other-window))