1 ;;; nxml-maint.el --- commands for maintainers of nxml-*.el
3 ;; Copyright (C) 2003, 2007, 2008, 2009, 2010
4 ;; Free Software Foundation, Inc.
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;;; Generating files with Unicode char names.
32 (defun nxml-create-unicode-char-name-sets (file)
33 "Generate files containing char names from Unicode standard."
34 (interactive "fUnicodeData file: ")
36 (let ((nameset (nxml-unicode-block-char-name-set (nth 0 block))))
38 (find-file (concat (get nameset 'nxml-char-name-set-file)
41 (insert "(nxml-define-char-name-set '")
42 (prin1 nameset (current-buffer))
44 (goto-char (- (point) 3)))))
48 (goto-char (point-min))
49 (let ((blocks nxml-unicode-blocks)
51 (while (re-search-forward "^\\([0-9A-F]+\\);\\([^<;][^;]*\\);"
54 (setq code (string-to-number (match-string 1) 16))
55 (setq name (match-string 2))
57 (> code (nth 2 (car blocks))))
58 (setq blocks (cdr blocks)))
59 (when (and (<= (nth 1 (car blocks)) code)
60 (<= code (nth 2 (car blocks))))
62 (find-file (concat (get (nxml-unicode-block-char-name-set
64 'nxml-char-name-set-file)
67 (prin1 name (current-buffer))
68 (insert (format " #x%04X)\n " code))))))))
70 ;;; Parsing target repertoire files from ucs-fonts.
71 ;; This is for converting the TARGET? files in
72 ;; http://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts.tar.gz
75 (defun nxml-insert-target-repertoire-glyph-set (file var)
76 (interactive "fTarget file: \nSVariable name: ")
78 (with-current-buffer (find-file-noselect file)
79 (goto-char (point-min))
80 (while (re-search-forward "^ *\\([a-FA-F0-9]\\{2\\}\\)[ \t]+" nil t)
81 (let ((row (match-string 1))
82 (eol (line-end-position)))
83 (while (re-search-forward "\\([a-FA-F0-9]\\{2\\}\\)-\\([a-FA-F0-9]\\{2\\}\\)\\|\\([a-FA-F0-9]\\{2\\}\\)" eol t)
85 (cons (if (match-beginning 3)
86 (concat "#x" row (match-string 3))
87 (concat "(#x" row (match-string 1)
88 " . #x" row (match-string 2) ")"))
90 (setq lst (nreverse lst))
91 (insert (format "(defconst %s\n [" var))
96 (when (= (length head) 6)
97 (while (and lst (= (length (car lst)) 6))
100 (setq lst (cdr lst))))
101 (when lst (insert "\n ")))
104 (provide 'nxml-maint)
106 ;;; nxml-maint.el ends here